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;
}
Aggregations