List of usage examples for javax.swing JButton getClientProperty
public final Object getClientProperty(Object key)
From source file:com.nikonhacker.gui.EmulatorUI.java
private void applyPrefsToUI() { if (BUTTON_SIZE_LARGE.equals(prefs.getButtonSize())) { toolbarButtonMargin.set(2, 14, 2, 14); } else {/*from w ww .j ava 2s . co m*/ toolbarButtonMargin.set(0, 0, 0, 0); } if (BUTTON_SIZE_SMALL.equals(prefs.getButtonSize())) { //iterate on buttons and resize them to 16x16 for (int chip = 0; chip < 2; chip++) { for (Component component : toolBar[chip].getComponents()) { if (component instanceof JButton) { JButton button = (JButton) component; ImageIcon icon = (ImageIcon) button.getClientProperty(BUTTON_PROPERTY_KEY_ICON); if (icon != null) { Image newImg = icon.getImage().getScaledInstance(16, 16, java.awt.Image.SCALE_SMOOTH); button.setIcon(new ImageIcon(newImg)); } } } } } else { //iterate on buttons and revert to original icon for (int chip = 0; chip < 2; chip++) { for (Component component : toolBar[chip].getComponents()) { if (component instanceof JButton) { JButton button = (JButton) component; ImageIcon icon = (ImageIcon) button.getClientProperty(BUTTON_PROPERTY_KEY_ICON); if (icon != null) { button.setIcon(icon); } } } } } initProgrammableTimerAnimationIcons(prefs.getButtonSize()); for (int chip = 0; chip < 2; chip++) { toolBar[chip].revalidate(); } }