Search in sources :

Example 21 with JColorChooser

use of javax.swing.JColorChooser in project JMRI by JMRI.

the class DrawFrame method makePanel.

protected JPanel makePanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(new JLabel(Bundle.getMessage("lineWidth")));
    JPanel pp = new JPanel();
    pp.add(new JLabel(Bundle.getMessage("thin")));
    _lineSlider = new JSlider(SwingConstants.HORIZONTAL, 1, 30, _lineWidth);
    _lineSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            widthChange();
        }
    });
    pp.add(_lineSlider);
    pp.add(new JLabel(Bundle.getMessage("thick")));
    p.add(pp);
    panel.add(p);
    p = new JPanel();
    ButtonGroup bg = new ButtonGroup();
    _lineColorButon = new JRadioButton(Bundle.getMessage("lineColor"));
    p.add(_lineColorButon);
    bg.add(_lineColorButon);
    _fillColorButon = new JRadioButton(Bundle.getMessage("fillColor"));
    p.add(_fillColorButon);
    bg.add(_fillColorButon);
    _lineColorButon.setSelected(true);
    panel.add(p);
    _chooser = new JColorChooser(Color.LIGHT_GRAY);
    _chooser.setColor(Color.green);
    _chooser.getSelectionModel().addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            colorChange();
        }
    });
    _chooser.setPreviewPanel(new JPanel());
    panel.add(_chooser);
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(new JLabel(Bundle.getMessage("transparency")));
    pp = new JPanel();
    pp.add(new JLabel(Bundle.getMessage("transparent")));
    _alphaSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 255, _lineColor.getAlpha());
    _alphaSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            alphaChange();
        }
    });
    pp.add(_alphaSlider);
    _lineColorButon.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            buttonChange();
        }
    });
    pp.add(new JLabel(Bundle.getMessage("opaque")));
    p.add(pp);
    panel.add(p);
    panel.add(Box.createVerticalStrut(STRUT_SIZE));
    return panel;
}
Also used : JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ChangeEvent(javax.swing.event.ChangeEvent) ButtonGroup(javax.swing.ButtonGroup) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JSlider(javax.swing.JSlider) ChangeListener(javax.swing.event.ChangeListener) JColorChooser(javax.swing.JColorChooser)

Aggregations

JColorChooser (javax.swing.JColorChooser)21 JDialog (javax.swing.JDialog)7 JLabel (javax.swing.JLabel)6 JButton (javax.swing.JButton)5 Component (java.awt.Component)4 JFrame (javax.swing.JFrame)4 JPanel (javax.swing.JPanel)4 JCheckBox (javax.swing.JCheckBox)3 AbstractColorChooserPanel (javax.swing.colorchooser.AbstractColorChooserPanel)3 Color (java.awt.Color)2 Frame (java.awt.Frame)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ArrayList (java.util.ArrayList)2 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)2 JComponent (javax.swing.JComponent)2 JDesktopPane (javax.swing.JDesktopPane)2 JEditorPane (javax.swing.JEditorPane)2 JFileChooser (javax.swing.JFileChooser)2 JFormattedTextField (javax.swing.JFormattedTextField)2