public void itemStateChanged(ItemEvent e) { AbstractButton button = (AbstractButton) e.getSource(); DitherPanel parent = (DitherPanel) button.getParent(); if (e.getStateChange() == ItemEvent.SELECTED) { button.setIcon((Icon) button.getClientProperty(SELECTED)); parent.setDithering(true); parent.setBackground(ThemeFileHandler.FILTER_TITLE_COLOR.getValue()); } else { button.setIcon((Icon) button.getClientProperty(DESELECTED)); parent.setDithering(false); parent.setBackground(UIManager.getColor("TabbedPane.background")); } }
/** * Adds the given NamedMediaType. * * <p>Marks the 'Any Type' as selected. */ private void addMediaType(NamedMediaType type, String toolTip) { Icon icon = type.getIcon(); Icon disabledIcon = null; Icon rolloverIcon = null; AbstractButton button = new JRadioButton(type.getName()); button.putClientProperty(MEDIA, type); button.putClientProperty(SELECTED, icon); if (icon != null) { disabledIcon = ImageManipulator.darken(icon); rolloverIcon = ImageManipulator.brighten(icon); } button.putClientProperty(DESELECTED, disabledIcon); button.setIcon(disabledIcon); button.setRolloverIcon(rolloverIcon); button.addItemListener(HIGHLIGHTER); button.setBorderPainted(false); button.setFocusPainted(false); button.setContentAreaFilled(false); button.setMargin(new Insets(0, 0, 0, 0)); button.setOpaque(false); button.addMouseListener(CLICK_FORWARDER); button.setPreferredSize(new Dimension(100, 22)); if (toolTip != null) { button.setToolTipText(toolTip); } GROUP.add(button); DitherPanel panel = new DitherPanel(DITHERER); panel.setDithering(false); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 7, 1)); panel.add(button); panel.addMouseListener(CLICK_FORWARDER); panel.setBackground(UIManager.getColor("TabbedPane.background")); SCHEMAS.add(panel); if (type.getMediaType() == MediaType.getAnyTypeMediaType()) button.setSelected(true); else button.setSelected(false); }