<AWT Dev> RFR: 8264305: Create implementation for native accessibility peer for Statusbar java role

Pankaj Bansal pbansal at openjdk.java.net
Wed Jun 2 14:10:48 UTC 2021

Create implementation for native accessibility peer for Statusbar java role. I do not see any Swing component with StatusBar accessibility role, so I have created a component with the StatusBar role to test this. I have tested the implementation with the following example and a few more similar examples. I do not see any difference in Voice Over output.

    import javax.accessibility.Accessible;
    import javax.accessibility.AccessibleContext;
    import javax.accessibility.AccessibleRole;
    import javax.accessibility.AccessibleStateSet;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.Timer;
    import javax.swing.border.BevelBorder;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.text.DateFormat;

    public class StatusBarDemo {

        public static void main(String[] args) throws Exception {
            StatusBarDemo demo = new StatusBarDemo();

        void createAndShowGUI() {
            JFrame jframe = new JFrame("StatusBar Demo");
            jframe.setLayout(new BorderLayout());
            jframe.setSize(200, 200);

            // create the status bar panel and shove it down the bottom of the frame
            JPanel statusPanel = new StatusBar();
            statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
            statusPanel.setPreferredSize(new Dimension(jframe.getWidth(), 16));
            statusPanel.setLayout(new BorderLayout());

            JLabel date = new JLabel();
            statusPanel.setLayout(new BorderLayout());
            statusPanel.add(date, BorderLayout.CENTER);

            Timer timer = new javax.swing.Timer(1000, new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    java.util.Date now = new java.util.Date();
                    String ss = DateFormat.getDateTimeInstance().format(now);
                    date.setToolTipText("Welcome, Today is " + ss);



            jframe.add(statusPanel, BorderLayout.SOUTH);


        class StatusBar extends JPanel implements Accessible {

            AccessibleContext accessibleContext;

            public AccessibleContext getAccessibleContext() {
                if (accessibleContext == null) {
                    accessibleContext = new StatusBar.AccessibleJStatusBar();
                return accessibleContext;

            protected class AccessibleJStatusBar extends AccessibleJComponent {
                public AccessibleStateSet getAccessibleStateSet() {
                    AccessibleStateSet states = super.getAccessibleStateSet();
                    return states;
                public AccessibleRole getAccessibleRole() {
                    return AccessibleRole.STATUS_BAR;



Commit messages:
 - 8264305: Create implementation for native accessibility peer for Statusbar java role

Changes: https://git.openjdk.java.net/jdk/pull/4307/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4307&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8264305
  Stats: 41 lines in 3 files changed: 39 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4307.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4307/head:pull/4307

PR: https://git.openjdk.java.net/jdk/pull/4307

More information about the awt-dev mailing list