Java JComponent set accessible name

Description

Java JComponent set accessible name


import java.awt.FlowLayout;

import javax.swing.JCheckBox;
import javax.swing.JFrame;

public class Main extends JFrame {
  public Main() {
    super("JButton");

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(new FlowLayout());

    /*from   ww w.j a va2 s .  com*/
    JCheckBox checkBox = new JCheckBox("CheckBox");
    checkBox.getAccessibleContext().setAccessibleName("Button Name");

    getContentPane().add(checkBox);
  }

  public static void main(String[] args) {
    Main frame = new Main();
    frame.pack();
    frame.setVisible(true);
  }
}



PreviousNext

Related