/** * Maps {@code JColorChooser.getUI()} through queue */ public ColorChooserUI getUI() { return (runMapping(new MapAction<ColorChooserUI>("getUI") { @Override public ColorChooserUI map() { return ((JColorChooser) getSource()).getUI(); } })); }
/** * Maps {@code JColorChooser.setUI(ColorChooserUI)} through queue */ public void setUI(final ColorChooserUI colorChooserUI) { runMapping(new MapVoidAction("setUI") { @Override public void map() { ((JColorChooser) getSource()).setUI(colorChooserUI); } }); }
/** * This method resets the UI Component property to the Look and Feel * default. */ public void updateUI() { setUI((ColorChooserUI) UIManager.getUI(this)); }
public static JPopupButton createSelectionColorChooserButton(final DrawingEditor editor, final AttributeKey<Color> attributeKey, String labelKey, ResourceBundleUtil labels, @Nullable Map<AttributeKey, Object> defaultAttributes, Shape colorShape, @Nullable final Class uiclass, @Nullable final java.util.List<Disposable> dsp) { JPopupButton popupButton; popupButton = new JPopupButton(); labels.configureToolBarButton(popupButton, labelKey); popupButton.setFocusable(true); popupButton.setRequestFocusEnabled(false); // We lazily initialize the popup menu because creating a JColorChooser // takes a lot of time. JComponentPopup popupMenu = new JComponentPopup() { private JColorChooser colorChooser; @Override public void show(Component invoker, int x, int y) { if (colorChooser == null) { initialize(); } Color c; if (editor.getActiveView() != null && editor.getActiveView().getSelectionCount() > 0) { c = editor.getActiveView().getSelectedFigures().iterator().next().get(attributeKey); } else { c = editor.getDefaultAttribute(attributeKey); } colorChooser.setColor(c == null ? new Color(0, true) : c); super.show(invoker, x, y); } private void initialize() { colorChooser = new JColorChooser(); colorChooser.setOpaque(true); colorChooser.setBackground(Color.WHITE); if (uiclass != null) { try { colorChooser.setUI((ColorChooserUI) Methods.invokeStatic(uiclass, "createUI", new Class[]{JComponent.class}, new Object[]{colorChooser})); } catch (NoSuchMethodException ex) { ex.printStackTrace(); } } dsp.add(new SelectionColorChooserHandler(editor, attributeKey, colorChooser, this)); add(colorChooser); } }; popupButton.setPopupMenu(popupMenu); popupButton.setPopupAlpha(1.0f);// must be set after we set the popup menu Icon icon = new SelectionColorIcon(editor, attributeKey, labels.getIconProperty(labelKey, ButtonFactory.class).getImage(), colorShape); popupButton.setIcon(icon); popupButton.setDisabledIcon(icon); popupButton.setFocusable(false); if (dsp != null) { dsp.add(new SelectionComponentRepainter(editor, popupButton)); } return popupButton; }
public static JPopupButton createDrawingColorChooserButton(final DrawingEditor editor, final AttributeKey<Color> attributeKey, String labelKey, ResourceBundleUtil labels, @Nullable Map<AttributeKey, Object> defaultAttributes, Shape colorShape, @Nullable final Class uiclass, @Nullable final java.util.List<Disposable> dsp) { JPopupButton popupButton; popupButton = new JPopupButton(); labels.configureToolBarButton(popupButton, labelKey); popupButton.setFocusable(true); popupButton.setRequestFocusEnabled(false); // We lazily initialize the popup menu because creating a JColorChooser // takes a lot of time. JComponentPopup popupMenu = new JComponentPopup() { private JColorChooser colorChooser; @Override public void show(Component invoker, int x, int y) { if (colorChooser == null) { initialize(); } Color c; if (editor.getActiveView() != null) { c = editor.getActiveView().getDrawing().get(attributeKey); } else { c = editor.getDefaultAttribute(attributeKey); } colorChooser.setColor(c == null ? new Color(0, true) : c); super.show(invoker, x, y); } private void initialize() { colorChooser = new JColorChooser(); colorChooser.setOpaque(true); colorChooser.setBackground(Color.WHITE); if (uiclass != null) { try { colorChooser.setUI((ColorChooserUI) Methods.invokeStatic(uiclass, "createUI", new Class[]{JComponent.class}, new Object[]{colorChooser})); } catch (NoSuchMethodException ex) { ex.printStackTrace(); } } dsp.add(new DrawingColorChooserHandler(editor, attributeKey, colorChooser, this)); add(colorChooser); } }; popupButton.setPopupMenu(popupMenu); popupButton.setPopupAlpha(1.0f);// must be set after we set the popup menu Icon icon = new DrawingColorIcon(editor, attributeKey, labels.getIconProperty(labelKey, ButtonFactory.class).getImage(), colorShape); popupButton.setIcon(icon); popupButton.setDisabledIcon(icon); popupButton.setFocusable(false); if (dsp != null) { dsp.add(new SelectionComponentRepainter(editor, popupButton)); } return popupButton; }
public ColorChooserUI getUI() { return (ColorChooserUI) ui; }
public void setUI(ColorChooserUI ui) { super.setUI(ui); }
@Override public void updateUI() { setUI((ColorChooserUI) UIManager.getUI(this)); }
/** * Returns the L&F object that renders this component. * * @return the <code>ColorChooserUI</code> object that renders * this component */ public ColorChooserUI getUI() { return (ColorChooserUI)ui; }
/** * Sets the L&F object that renders this component. * * @param ui the <code>ColorChooserUI</code> L&F object * @see UIDefaults#getUI * * @beaninfo * bound: true * hidden: true * description: The UI object that implements the color chooser's LookAndFeel. */ public void setUI(ColorChooserUI ui) { super.setUI(ui); }
/** * Notification from the <code>UIManager</code> that the L&F has changed. * Replaces the current UI object with the latest version from the * <code>UIManager</code>. * * @see JComponent#updateUI */ public void updateUI() { setUI((ColorChooserUI)UIManager.getUI(this)); }
/** * Sets the L&F object that renders this component. * * @param ui the <code>ColorChooserUI</code> L&F object * @see UIDefaults#getUI */ @BeanProperty(hidden = true, description = "The UI object that implements the color chooser's LookAndFeel.") public void setUI(ColorChooserUI ui) { super.setUI(ui); }