use of javax.swing.JSlider in project JMRI by JMRI.
the class IndexedVarSlider method stateChanged.
@Override
public void stateChanged(ChangeEvent e) {
// called for new values of a slider - set the variable value as needed
// e.getSource() points to the JSlider object - find it in the list
JSlider j = (JSlider) e.getSource();
BoundedRangeModel r = j.getModel();
_iVar.setIntValue(r.getValue());
_iVar.setState(AbstractValue.EDITED);
}
use of javax.swing.JSlider in project JMRI by JMRI.
the class VSDManagerFrame method volumeChange.
/**
* (Debug only) Print the decoder list
*/
/*
private void debugPrintDecoderList() {
log.debug("Printing Decoder Lists from VSDManagerFrame...");
VSDecoderManager.instance().debugPrintDecoderList();
}
*/
/**
* Handle volume slider change
*/
protected void volumeChange(ChangeEvent e) {
JSlider v = (JSlider) e.getSource();
log.debug("Volume slider moved. value = " + v.getValue());
firePropertyChange(PropertyChangeID.VOLUME_CHANGE, v.getValue(), v.getValue());
}
use of javax.swing.JSlider 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;
}
use of javax.swing.JSlider in project JMRI by JMRI.
the class SpeedTableVarValue method getNewRep.
@Override
public Component getNewRep(String format) {
final int GRID_Y_BUTTONS = 3;
// put together a new panel in scroll pane
JPanel j = new JPanel();
GridBagLayout g = new GridBagLayout();
GridBagConstraints cs = new GridBagConstraints();
j.setLayout(g);
initStepCheckBoxes();
for (int i = 0; i < nValues; i++) {
cs.gridy = 0;
cs.gridx = i;
CvValue cv = _cvMap.get(cvList[i]);
JSlider s = new VarSlider(models[i], cv, i + 1);
s.setOrientation(JSlider.VERTICAL);
s.addChangeListener(this);
int currentState = cv.getState();
int currentValue = cv.getValue();
DecVariableValue decVal = new DecVariableValue("val" + i, "", "", false, false, false, false, cvList[i], "VVVVVVVV", _min, _max, _cvMap, _status, "");
decVal.setValue(currentValue);
decVal.setState(currentState);
Component v = decVal.getCommonRep();
String start = ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("TextStep") + " " + (i + 1);
((JTextField) v).setToolTipText(PaneProgPane.addCvDescription(start, "CV " + cvList[i], null));
// pack tighter
((JComponent) v).setBorder(null);
if (mfx && (i == 0 || i == (nValues - 1))) {
// disable field editing
((JTextField) v).setEditable(false);
// disable slider adjustment
s.setEnabled(false);
}
g.setConstraints(v, cs);
if (i == 0 && log.isDebugEnabled()) {
log.debug("Font size " + v.getFont().getSize());
}
float newSize = v.getFont().getSize() * 0.8f;
v.setFont(jmri.util.FontUtil.deriveFont(v.getFont(), newSize));
j.add(v);
cs.gridy++;
g.setConstraints(s, cs);
j.add(s);
cs.gridy++;
JCheckBox b = stepCheckBoxes.get(i);
g.setConstraints(b, cs);
j.add(b, cs);
}
// add control buttons
JPanel k = new JPanel();
JButton b;
k.add(b = new JButton(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("ButtonForceStraight")));
b.setToolTipText(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("TooltipForceStraight"));
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
doForceStraight(e);
}
});
k.add(b = new JButton(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("ButtonMatchEnds")));
b.setToolTipText(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("TooltipMatchEnds"));
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
doMatchEnds(e);
}
});
k.add(b = new JButton(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("ButtonConstantRatio")));
b.setToolTipText(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("TooltipConstantRatio"));
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
doRatioCurve(e);
}
});
k.add(b = new JButton(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("ButtonLogCurve")));
b.setToolTipText(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("TooltipLogCurve"));
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
doLogCurve(e);
}
});
k.add(b = new JButton(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("ButtonShiftLeft")));
b.setToolTipText(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("TooltipShiftLeft"));
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
doShiftLeft(e);
}
});
k.add(b = new JButton(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("ButtonShiftRight")));
b.setToolTipText(ResourceBundle.getBundle("jmri.jmrit.symbolicprog.SymbolicProgBundle").getString("TooltipShiftRight"));
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
doShiftRight(e);
}
});
cs.gridy = GRID_Y_BUTTONS;
cs.gridx = 0;
cs.gridwidth = GridBagConstraints.RELATIVE;
g.setConstraints(k, cs);
// add Vstart & Vhigh if applicable
JPanel l = new JPanel();
JPanel val = new JPanel();
val.setLayout(new BorderLayout());
val.add(j, BorderLayout.NORTH);
val.add(k, BorderLayout.CENTER);
if (mfx) {
val.add(l, BorderLayout.SOUTH);
}
updateRepresentation(val);
return val;
}
use of javax.swing.JSlider in project JMRI by JMRI.
the class SpeedTableVarValue method stateChanged.
/**
* Called for new values of a slider.
* <P>
* Sets the CV(s) as needed.
*
*/
@Override
public void stateChanged(ChangeEvent e) {
// e.getSource() points to the JSlider object - find it in the list
JSlider j = (JSlider) e.getSource();
BoundedRangeModel r = j.getModel();
for (int i = 0; i < nValues; i++) {
if (r == models[i]) {
// found it, and i is useful!
setModel(i, r.getValue());
// no need to continue loop
break;
}
}
// notify that Value property changed
prop.firePropertyChange("Value", null, j);
}
Aggregations