Setting an Accessible Name for an Image Button - Java Swing

Java examples for Swing:JButton

Description

Setting an Accessible Name for an Image Button

Demo Code

import javax.swing.ImageIcon;
import javax.swing.JButton;

public class Main {
  public static void main(String[] args) {
    JButton button = new JButton(new ImageIcon("image.gif"));
    button.setToolTipText("Button Name");

    button.getAccessibleContext().setAccessibleName("Button Name");
  }/*from  w  w w. j  a v a  2s .  c  o m*/
}

Related Tutorials