On Wed, 2 Jun 2021 13:58:24 GMT, Pankaj Bansal <pban...@openjdk.org> wrote:
> 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(); > SwingUtilities.invokeAndWait(demo::createAndShowGUI); > } > > void createAndShowGUI() { > JFrame jframe = new JFrame("StatusBar Demo"); > jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); > 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(); > date.setOpaque(true); > date.setBackground(Color.black); > date.setForeground(Color.WHITE); > statusPanel.setLayout(new BorderLayout()); > statusPanel.setBackground(Color.LIGHT_GRAY); > statusPanel.add(date, BorderLayout.CENTER); > > > Timer timer = new javax.swing.Timer(1000, new ActionListener() { > @Override > public void actionPerformed(ActionEvent e) { > java.util.Date now = new java.util.Date(); > String ss = DateFormat.getDateTimeInstance().format(now); > date.setText(ss); > date.setToolTipText("Welcome, Today is " + ss); > > } > }); > > timer.start(); > > jframe.add(statusPanel, BorderLayout.SOUTH); > > jframe.setLocationRelativeTo(null); > jframe.setVisible(true); > } > > 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; > } > } > } > } > > > ` This pull request has now been integrated. Changeset: 3025f059 Author: Pankaj Bansal <pban...@openjdk.org> URL: https://git.openjdk.java.net/jdk/commit/3025f05970ede82c6f67a0434e33b27205e10130 Stats: 41 lines in 3 files changed: 39 ins; 0 del; 2 mod 8264305: Create implementation for native accessibility peer for Statusbar java role Reviewed-by: kizune ------------- PR: https://git.openjdk.java.net/jdk/pull/4307