本文整理汇总了Java中javax.swing.JSpinner.addChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java JSpinner.addChangeListener方法的具体用法?Java JSpinner.addChangeListener怎么用?Java JSpinner.addChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JSpinner
的用法示例。
在下文中一共展示了JSpinner.addChangeListener方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import javax.swing.JSpinner; //导入方法依赖的package包/类
private void init() {
spinnerModel = new SpinnerNumberModel(0, 0, 500, 1);
spinner = new JSpinner(spinnerModel);
spinner.setFont(new java.awt.Font("",0,15));
gbLayout = new GridBagLayout();
gbConst = new GridBagConstraints();
panel = new JPanel();
setLabel("");
panel.setLayout(gbLayout);
setMinimum(0);
setMaximum(500);
spinner.addChangeListener(new SpinnerListener());
gbConst.gridx = 0; gbConst.gridy = 0;
gbLayout.setConstraints(spinner, gbConst);
panel.add(spinner);
}
示例2: ControlsPanel
import javax.swing.JSpinner; //导入方法依赖的package包/类
private ControlsPanel() {
cmbPaint = createCombo(this, paintType);
cmbPaint.setSelectedIndex(1);
cmbCycle = createCombo(this, cycleMethod);
cmbSpace = createCombo(this, colorSpace);
cmbShape = createCombo(this, shapeType);
cmbXform = createCombo(this, xformType);
int max = COLORS.length;
SpinnerNumberModel model = new SpinnerNumberModel(max, 2, max, 1);
spinNumColors = new JSpinner(model);
spinNumColors.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
numColors = ((Integer)spinNumColors.getValue()).intValue();
gradientPanel.updatePaint();
}
});
add(spinNumColors);
cbAntialias = createCheck(this, "Antialiasing");
cbRender = createCheck(this, "Render Quality");
}
示例3: createComponents
import javax.swing.JSpinner; //导入方法依赖的package包/类
@Override
protected void createComponents() {
super.createComponents();
{
final JLabel binCountLabel = new ResourceLabel("plotter.configuration_dialog.bin_count");
// create input text field
binCountSpinner = new JSpinner(new SpinnerNumberModel(5, 1, null, 1));
binCountLabel.setLabelFor(binCountSpinner);
binCountSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
binCountChanged();
}
});
addTwoComponentRow(this, binCountLabel, binCountSpinner);
}
final JPanel spacerPanel = new JPanel();
final GridBagConstraints itemConstraint = new GridBagConstraints();
itemConstraint.fill = GridBagConstraints.BOTH;
itemConstraint.weightx = 1;
itemConstraint.weighty = 1;
itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
this.add(spacerPanel, itemConstraint);
}
示例4: initComponents
import javax.swing.JSpinner; //导入方法依赖的package包/类
/**
* Initialize all gui objects
*/
private void initComponents() {
setLayout(new BorderLayout());
JPanel topPanel = new JPanel(new GridLayout(2, 1));
topPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
JLabel label = new JLabel("Execution number: ");
final JSpinner spinner = new JSpinner();
spinner.setPreferredSize(DIM_SPINNER);
spinner.setValue(new Integer(1));
label.setLabelFor(spinner);
// Pack spinner and its label on top, while description is on the second line
JPanel tmp = new JPanel();
tmp.add(label);
tmp.add(spinner);
topPanel.add(tmp);
description.setHorizontalAlignment(SwingConstants.CENTER);
topPanel.add(description);
// Adds state change to spinner.
spinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
int i = ((Integer) spinner.getValue()).intValue();
if (i <= 0) {
i = 1;
}
if (i > model.getWhatIfValues().length) {
i = model.getWhatIfValues().length;
}
select(i - 1);
spinner.setValue(new Integer(i));
}
});
add(topPanel, BorderLayout.NORTH);
add(tabber, BorderLayout.CENTER);
select(0);
}
示例5: createComponents
import javax.swing.JSpinner; //导入方法依赖的package包/类
private void createComponents() {
vp = new VisualisationPanel(this);
JPanel wp = new JPanel(new BorderLayout());
wp.add(vp, BorderLayout.CENTER);
container.setLayout(new BorderLayout());
wp.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(5, 10, 10, 10),
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)));
container.add(wp, BorderLayout.CENTER);
infoPanel = new JPanel();
infoPanel.setLayout(new FlowLayout());
infoLabel = new JLabel("No problem to display.");
samplingSpinner = new JSpinner(new SpinnerNumberModel(
SAMPLING_PERIOD_INIT, 1, null, 1));
samplingSpinner.addChangeListener(samplingListener);
samplingSpinner.setPreferredSize(new Dimension(50, 20));
samplingSpinner.setVisible(false);
vp.setSamplingPeriod(SAMPLING_PERIOD_INIT);
infoPanel.add(infoLabel);
infoPanel.add(samplingSpinner);
container.add(infoPanel, BorderLayout.NORTH);
createMenus();
createAnimationControls();
}
示例6: createLabelField
import javax.swing.JSpinner; //导入方法依赖的package包/类
public static JPanel createLabelField(String preText, String postText, JSlider s) {
JPanel p = new JPanel();
JSpinner spin = new JSpinner(new SpinnerNumberModel(s.getValue(), s.getMinimum(), s.getMaximum(), 1));
spin.addChangeListener(ce -> {s.setValue((Integer) spin.getValue());});
p.add(new JLabel(preText));
p.add(spin);
p.add(new JLabel(postText));
return p;
}
示例7: subscribeActual
import javax.swing.JSpinner; //导入方法依赖的package包/类
@Override
protected void subscribeActual(Observer<? super ChangeEvent> observer) {
JSpinner w = widget;
ChangeEventConsumer aec = new ChangeEventConsumer(observer, w);
observer.onSubscribe(aec);
w.addChangeListener(aec);
if (aec.get() == null) {
aec.onDispose(w);
}
}
示例8: createSpinner
import javax.swing.JSpinner; //导入方法依赖的package包/类
void createSpinner(Method methodToCall, double value, double min, double max, double step,
String label) {
JSpinner spinner =
new MySpinner(methodToCall, this.layout, this.item, value, min, max, step);
spinner.addChangeListener(this);
JLabel l = new JLabel(label);
this.add(l);
l.setLabelFor(spinner);
this.add(spinner);
}
示例9: createContentPanel
import javax.swing.JSpinner; //导入方法依赖的package包/类
private Container createContentPanel() {
final JPanel panel = new JPanel() {
@Override
public void paint(Graphics g) {
super.paint(g);
model.paint((Graphics2D) g, this.getBounds());
}
};
final JPanel res = new JPanel(new BorderLayout());
res.add(panel, BorderLayout.CENTER);
final JSpinner slider = new JSpinner(
new SpinnerNumberModel(4, 2, 8, 1) {
});
res.add(slider, BorderLayout.SOUTH);
slider.addChangeListener(new ChangeListener() {
public void stateChanged(final ChangeEvent e) {
model.setCount(((Number) slider.getValue()).intValue());
TestFrame.this.repaint();
}
});
return res;
}
示例10: bug6463712
import javax.swing.JSpinner; //导入方法依赖的package包/类
public bug6463712() {
SpinnerNumberModel m1 = new SpinnerNumberModel();
JSpinner s = new JSpinner(m1);
s.addChangeListener(this);
SpinnerDateModel m2 = new SpinnerDateModel();
s.setModel(m2);
// m1 is no longer linked to the JSpinner (it has been replaced by m2), so
// the following should not trigger a call to our stateChanged() method...
m1.setValue(new Integer(1));
}
示例11: BracketingList
import javax.swing.JSpinner; //导入方法依赖的package包/类
public BracketingList(String cname, int size)
{
super(new MigLayout("fill"), false);
model = new BracketingListModel();
required = size;
spinner = new JSpinner(new SpinnerNumberModel(size, size/2+1, size, 1));
spinner.addChangeListener(this);
ladiesCheck = new JCheckBox("Ladies Classes", true);
ladiesCheck.addChangeListener(this);
openCheck = new JCheckBox("Open Classes", true);
openCheck.addChangeListener(this);
bonusCheck = new JCheckBox("Bonus Style Dialins", true);
bonusCheck.addChangeListener(this);
table = new JTable(model);
table.setAutoCreateRowSorter(true);
table.setDefaultRenderer(Double.class, new D3Renderer());
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table.getColumnModel().getColumn(0).setMaxWidth(50);
table.getColumnModel().getColumn(1).setMaxWidth(200);
table.getColumnModel().getColumn(2).setMaxWidth(200);
table.getColumnModel().getColumn(3).setMaxWidth(75);
table.getColumnModel().getColumn(4).setMaxWidth(75);
mainPanel.add(new JLabel("Number of Drivers"), "split");
mainPanel.add(spinner, "gapbottom 10, wrap");
mainPanel.add(ladiesCheck, "wrap");
mainPanel.add(openCheck, "wrap");
mainPanel.add(bonusCheck, "gapbottom 10, wrap");
mainPanel.add(new JLabel("Click on column header to sort"), "center, wrap");
mainPanel.add(new JScrollPane(table), "width 400, height 600, grow");
}