![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e750. Adding a Disabled Icon to a JButton ComponentBy default, when a button is disabled, it automatically generates a grayed-out version of the installed icon. However, it is possible to set a specific icon to use when the button is disabled.// To create a button with an icon, see e746 Adding an Icon to a JButton Component // Icon will appear gray button.setEnabled(false); // Set a disabled version of icon Icon disabledIcon = new ImageIcon("dicon.gif"); button.setDisabledIcon(disabledIcon); // To remove the disabled version of the icon, set to null button.setDisabledIcon(null); // If original icon is set as the disabled icon, disabling // the button will have no effect on the icon button.setDisabledIcon(icon);
e744. Changing the Label of a JButton Component e745. Creating a Multiline Label for a JButton Component e746. Adding an Icon to a JButton Component e747. Moving the Icon in a JButton Component e748. Moving the Label/Icon Pair in a JButton Component e749. Setting the Gap Size Between the Label and Icon in a JButton Component e751. Adding a Rollover and Pressed Icon to a JButton Component © 2002 Addison-Wesley. |