Sun Java Solaris Communities My SDN Account Join SDN
 
Code sample

Code Samples from the Java Developers Almanac 2000

 

Code Samples Index

These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms

Setting an Accessible Name for an Image Button

You should also set the accessible name for components that only show an image. The tool tip text, if set, serves as the accessible name for a component. However, if the tool tip text is being used for something else, set the component's accessible name.

    
 JButton button = new JButton(new ImageIcon("image.gif"));
 button.setToolTipText("Button Name");
     
 // If tool tip is being used for something else,
 // set the accessible name.
 button.getAccessibleContext().setAccessibleName(
   "Button Name");
 
 

Examplets provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan.
Order this book from Amazon