protected void buildChooser() { String redString = UIManager.getString("ColorChooser.rgbRedText"); String greenString = UIManager.getString("ColorChooser.rgbGreenText"); String blueString = UIManager.getString("ColorChooser.rgbBlueText"); setLayout(new BorderLayout()); Color color = getColorFromModel(); JPanel enclosure = new JPanel(); enclosure.setLayout(new SmartGridLayout(3, 3)); enclosure.setInheritsPopupMenu(true); // The panel that holds the sliders add(enclosure, BorderLayout.CENTER); // sliderPanel.setBorder(new LineBorder(Color.black)); // The row for the red value JLabel l = new JLabel(redString); l.setDisplayedMnemonic(AbstractColorChooserPanel.getInt("ColorChooser.rgbRedMnemonic", -1)); enclosure.add(l); redSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getRed()); redSlider.setMajorTickSpacing(85); redSlider.setMinorTickSpacing(17); redSlider.setPaintTicks(true); redSlider.setPaintLabels(true); redSlider.setInheritsPopupMenu(true); enclosure.add(redSlider); redField = new JSpinner(new SpinnerNumberModel(color.getRed(), minValue, maxValue, 1)); l.setLabelFor(redSlider); redField.setInheritsPopupMenu(true); JPanel redFieldHolder = new JPanel(new CenterLayout()); redFieldHolder.setInheritsPopupMenu(true); redField.addChangeListener(this); redFieldHolder.add(redField); enclosure.add(redFieldHolder); // The row for the green value l = new JLabel(greenString); l.setDisplayedMnemonic(AbstractColorChooserPanel.getInt("ColorChooser.rgbGreenMnemonic", -1)); enclosure.add(l); greenSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getGreen()); greenSlider.setMajorTickSpacing(85); greenSlider.setMinorTickSpacing(17); greenSlider.setPaintTicks(true); greenSlider.setPaintLabels(true); greenSlider.setInheritsPopupMenu(true); enclosure.add(greenSlider); greenField = new JSpinner(new SpinnerNumberModel(color.getGreen(), minValue, maxValue, 1)); l.setLabelFor(greenSlider); greenField.setInheritsPopupMenu(true); JPanel greenFieldHolder = new JPanel(new CenterLayout()); greenFieldHolder.add(greenField); greenFieldHolder.setInheritsPopupMenu(true); greenField.addChangeListener(this); enclosure.add(greenFieldHolder); // The slider for the blue value l = new JLabel(blueString); l.setDisplayedMnemonic(AbstractColorChooserPanel.getInt("ColorChooser.rgbBlueMnemonic", -1)); enclosure.add(l); blueSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getBlue()); blueSlider.setMajorTickSpacing(85); blueSlider.setMinorTickSpacing(17); blueSlider.setPaintTicks(true); blueSlider.setPaintLabels(true); blueSlider.setInheritsPopupMenu(true); enclosure.add(blueSlider); blueField = new JSpinner(new SpinnerNumberModel(color.getBlue(), minValue, maxValue, 1)); l.setLabelFor(blueSlider); blueField.setInheritsPopupMenu(true); JPanel blueFieldHolder = new JPanel(new CenterLayout()); blueFieldHolder.add(blueField); blueField.addChangeListener(this); blueFieldHolder.setInheritsPopupMenu(true); enclosure.add(blueFieldHolder); redSlider.addChangeListener(this); greenSlider.addChangeListener(this); blueSlider.addChangeListener(this); redSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE); greenSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE); blueSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE); }
public void uninstallChooserPanel(JColorChooser enclosingChooser) { super.uninstallChooserPanel(enclosingChooser); removeAll(); }
/** * {@collect.stats} The background color, foreground color, and font are already set to the * defaults from the defaults table before this method is called. */ public void installChooserPanel(JColorChooser enclosingChooser) { super.installChooserPanel(enclosingChooser); }