本文整理汇总了Java中javax.swing.JSpinner.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java JSpinner.setValue方法的具体用法?Java JSpinner.setValue怎么用?Java JSpinner.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JSpinner
的用法示例。
在下文中一共展示了JSpinner.setValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReactsAndHasChanged
import javax.swing.JSpinner; //导入方法依赖的package包/类
/**
* Test of class TimeoutValueHandler's ability to toggle whether it reacts and the
* log of whether it changed.
*/
@Test
public void testReactsAndHasChanged() {
System.out.println("ReactsAndHasChanged");
JComboBox<String> comboBox = new JComboBox<String>();
JSpinner spinner = new JSpinner();
DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
model.addElement("s");
model.addElement("m");
model.addElement("h");
model.addElement("d");
comboBox.setModel(model);
TimeoutValueHandler handler = new TimeoutValueHandler(spinner, comboBox);
boolean hasChangedBeforeTest = handler.hasChanged();
handler.setReacts(true);
spinner.setValue(11);
comboBox.setSelectedIndex(2);
handler.setValue(handler.getTimeout());
boolean hasChangedAfterInput = handler.hasChanged();
handler.setHasChanged(false);
handler.setReacts(false);
spinner.setValue(27);
comboBox.setSelectedIndex(1);
boolean hasChangedAfterStopReact = handler.hasChanged();
assertTrue(!hasChangedBeforeTest && hasChangedAfterInput && !hasChangedAfterStopReact);
}
示例2: ComparePanel
import javax.swing.JSpinner; //导入方法依赖的package包/类
public ComparePanel()
{
dateSpinner = new JSpinner( new SpinnerDateModel() );
JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(dateSpinner, "dd.MM.yyyy");
dateSpinner.setEditor(dateEditor);
dateSpinner.setValue(new Date());
timeSpinner = new JSpinner( new SpinnerDateModel() );
JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "HH:mm:ss");
timeSpinner.setEditor(timeEditor);
timeSpinner.setValue(new Date());
}
示例3: 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);
}
示例4: initComponents
import javax.swing.JSpinner; //导入方法依赖的package包/类
private void initComponents() {
this.setBorder(new EmptyBorder(5, 5, 5, 5));
this.setLayout(new BorderLayout(5, 5));
infiniteQueueSelector = new JRadioButton("Infinite");
finiteQueueSelector = new JRadioButton("Finite");
queueLengthGroup = new ButtonGroup();
queueLengthGroup.add(infiniteQueueSelector);
queueLengthGroup.add(finiteQueueSelector);
queueLengthSpinner = new JSpinner();
queueLengthSpinner.setValue(new Integer(1));
queueLengthSpinner.setPreferredSize(DIM_BUTTON_XS);
queueTable = new QueueTable();
//queue details panel
JPanel queuePolicyPanel = new JPanel(new BorderLayout());
queuePolicyPanel.setBorder(new TitledBorder(new EtchedBorder(), "Queue Policy"));
queuePolicyPanel.add(new WarningScrollTable(queueTable, WARNING_CLASS), BorderLayout.CENTER);
JPanel queueLengthPanel = new JPanel(new GridLayout(3, 1, 3, 3));
queueLengthPanel.setBorder(new TitledBorder(new EtchedBorder(), "Capacity"));
// Queue strategy selector
JPanel queueStrategy = new JPanel(new BorderLayout());
queueStrategy.add(new JLabel("Station queue policy: "), BorderLayout.WEST);
queuePolicyCombo = new JComboBox();
queueStrategy.add(queuePolicyCombo, BorderLayout.CENTER);
queuePolicyPanel.add(queueStrategy, BorderLayout.NORTH);
queueStrategy.setBorder(BorderFactory.createEmptyBorder(2, 5, 10, 5));
queueLengthPanel.add(infiniteQueueSelector);
queueLengthPanel.add(finiteQueueSelector);
JPanel spinnerPanel = new JPanel();
JLabel label = new JLabel("<html>Max no. customers <br>(queue+service)</html>");
label.setToolTipText("The maximum number of customers allowed in the station.");
spinnerPanel.add(label);
spinnerPanel.add(queueLengthSpinner);
queueLengthPanel.add(spinnerPanel);
this.add(queueLengthPanel, BorderLayout.WEST);
this.add(queuePolicyPanel, BorderLayout.CENTER);
}
示例5: actionPerformed
import javax.swing.JSpinner; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e)
{
JSpinner locSpinner = this.spinner;
if( !(e.getSource() instanceof javax.swing.Timer) )
{
// Most likely resulting from being in ActionMap.
locSpinner = eventToSpinner(e);
}
if( locSpinner != null )
{
try
{
int calendarField = getCalendarField(locSpinner);
locSpinner.commitEdit();
if( calendarField != -1 )
{
((SpinnerDateModel) locSpinner.getModel()).setCalendarField(calendarField);
}
Object value = (isNext) ? locSpinner.getNextValue() : locSpinner.getPreviousValue();
if( value != null )
{
locSpinner.setValue(value);
select(locSpinner);
}
}
catch( IllegalArgumentException iae )
{
UIManager.getLookAndFeel().provideErrorFeedback(locSpinner);
}
catch( ParseException pe )
{
UIManager.getLookAndFeel().provideErrorFeedback(locSpinner);
}
}
}
示例6: mouseWheelMoved
import javax.swing.JSpinner; //导入方法依赖的package包/类
@Override
public void mouseWheelMoved(final MouseWheelEvent mwe) {
final JSpinner spinner = (JSpinner) mwe.getSource();
if (mwe.getScrollType() != MouseWheelEvent.WHEEL_UNIT_SCROLL) {
return;
}
try {
int value = (Integer) spinner.getValue();
int i = 0;
for (i = 0; i < vals.length; i++) {
if (value < vals[i]) {
break;
}
}
if (i >= vals.length) {
i = vals.length - 1;
}
final int mult = mults[i];
value -= mult * mwe.getWheelRotation();
if (value < 0) {
value = 0;
}
spinner.setValue(value);
}
catch (final Exception e) {
DavisUserControlPanel.log.warning(e.toString());
return;
}
}
示例7: setupInstance
import javax.swing.JSpinner; //导入方法依赖的package包/类
protected void setupInstance(JSpinner instance) {
super.setupInstance(instance);
if (value != null) instance.setValue(value);
}
示例8: testTimeout
import javax.swing.JSpinner; //导入方法依赖的package包/类
/**
* Test of class TimeoutValueHandler testing both input and output at different configurations.
*/
@Test
public void testTimeout() {
System.out.println("set/getTimeout");
JComboBox<String> comboBox = new JComboBox<String>();
JSpinner spinner = new JSpinner();
DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
model.addElement("s");
model.addElement("m");
model.addElement("h");
model.addElement("d");
model.addElement("faultyEntry");
comboBox.setModel(model);
TimeoutValueHandler handler = new TimeoutValueHandler(spinner, comboBox);
handler.setReacts(true);
spinner.setValue(1);
comboBox.setSelectedIndex(2);
TimeOut expResult = new TimeOut(TimeUnit.SECONDS, 0);
spinner.setValue(0);
comboBox.setSelectedIndex(0);
handler.setValue(handler.getTimeout());
TimeOut result = handler.getTimeout();
boolean minTest = (expResult.getDuration() == result.getDuration()
&& expResult.getOrigUnit().equals(result.getOrigUnit())
&& !result.isActive());
expResult = new TimeOut(TimeUnit.DAYS, 3653);
spinner.setValue(3653);
comboBox.setSelectedIndex(3);
handler.setValue(handler.getTimeout());
result = handler.getTimeout();
boolean maxTest = (expResult.getDuration() == result.getDuration()
&& expResult.getOrigUnit().equals(result.getOrigUnit())
&& result.isActive());
expResult = new TimeOut(TimeUnit.DAYS, 0);
spinner.setValue(-1);
handler.setValue(handler.getTimeout());
result = handler.getTimeout();
boolean falseValueTest = (expResult.getDuration() == result.getDuration()
&& expResult.getOrigUnit().equals(result.getOrigUnit())
&& !result.isActive());
expResult = new TimeOut(TimeUnit.SECONDS, 0);
spinner.setValue(42);
comboBox.setSelectedIndex(4);
handler.setValue(handler.getTimeout());
result = handler.getTimeout();
//System.out.println(handler.hasChanged() + " max " + handler.getTimeout().getDuration() + " " + handler.getTimeout().getOrigUnit());
//System.out.println(handler.hasChanged() + " max " + expResult.getDuration() + " " + expResult.getOrigUnit());
boolean falseUnitTest = (expResult.getDuration() == result.getDuration()
&& expResult.getOrigUnit().equals(result.getOrigUnit())
&& !result.isActive());
assertTrue(minTest && maxTest && falseValueTest && falseUnitTest);
}
示例9: initPanel
import javax.swing.JSpinner; //导入方法依赖的package包/类
private void initPanel() {
this.setLayout(new GridLayout(1, 1));
Box mainPanel = Box.createHorizontalBox();
mainPanel.add(Box.createHorizontalStrut(5));
/** Pannello principale centrale **/
JPanel centralMainP = new JPanel(new BorderLayout(5, 10));
/** Upper Panel **/
JPanel upperP = new JPanel(new BorderLayout(5, 5));
/** Stringa infos clustering **/
String current = new String(INFO_CLUSTERING);
current = current.replaceFirst("X", Integer.toString(numClust));
current = current.replaceFirst("Y", defaultFormat.format(entropy));
infoClustering = new JLabel(current);
upperP.add(infoClustering, BorderLayout.NORTH);
/** Pannello selezione fuzzy error**/
JPanel fuzzyErrorP = new JPanel(new GridLayout(1, 2));
/** Pannello text,spinner,button fuzzy error**/
JPanel leftFuzzy = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
JLabel testoSpinner = new JLabel("Select the error: ");
fuzzyError = new JSpinner(new SpinnerNumberModel(0.1, 0.01, 0.99, 0.01));
fuzzyError.setValue(new Double(infos.getError()));
fuzzyError.setPreferredSize(new Dimension(60, 25));
selectErrore = new JButton("Apply error");
selectErrore.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
/** Impostazione errore per visualizzazione matrice dispersione **/
infos.setError(m, ((Double) fuzzyError.getValue()).doubleValue());
matrix.setFuzzyNess(((Double) fuzzyError.getValue()).doubleValue());
((clustDetModel) clusteringFinalTable.getModel()).setInfos(infos.numElem, infos.percent);
fPanel.setInfos();
/** Impostazioni valori per tabella **/
}
});
leftFuzzy.add(testoSpinner);
leftFuzzy.add(fuzzyError);
leftFuzzy.add(selectErrore);
/** Pannello con testo descrizione error **/
descrSetError = new JLabel(DESCR_ERRROR);
fuzzyErrorP.add(leftFuzzy);
fuzzyErrorP.add(descrSetError);
upperP.add(fuzzyErrorP, BorderLayout.SOUTH);
/** Table results **/
centralMainP.add(getUpperTable(), BorderLayout.CENTER);
centralMainP
.add(
new JLabel(
"<HTML><b><font size = 4>WARNING</font></b><br><font size=3>The sum can be greater than 100% due to multiple observations assignement<br></font>"),
BorderLayout.SOUTH);
centralMainP.add(upperP, BorderLayout.NORTH);
mainPanel.add(centralMainP);
mainPanel.add(Box.createHorizontalStrut(5));
this.add(mainPanel);
}
示例10: initComponents
import javax.swing.JSpinner; //导入方法依赖的package包/类
private void initComponents() {
this.setBorder(new EmptyBorder(5, 5, 5, 5));
this.setLayout(new BorderLayout(5, 5));
infiniteQueueSelector = new JRadioButton("infinite");
finiteQueueSelector = new JRadioButton("finite");
queueLengthGroup = new ButtonGroup();
queueLengthGroup.add(infiniteQueueSelector);
queueLengthGroup.add(finiteQueueSelector);
queueLengthSpinner = new JSpinner();
queueLengthSpinner.setValue(new Integer(1));
queueLengthSpinner.setPreferredSize(DIM_BUTTON_XS);
queueTable = new QueueTable();
//queue details panel
JPanel queuePolicyPanel = new JPanel(new BorderLayout());
queuePolicyPanel.setBorder(new TitledBorder(new EtchedBorder(), "Queue Policy"));
queuePolicyPanel.add(new WarningScrollTable(queueTable, WARNING_CLASS), BorderLayout.CENTER);
JPanel queueLengthPanel = new JPanel(new GridLayout(3, 1, 3, 3));
queueLengthPanel.setBorder(new TitledBorder(new EtchedBorder(), "Capacity"));
// Queue strategy selector
JPanel queueStrategy = new JPanel(new BorderLayout());
queueStrategy.add(new JLabel("Station queue policy: "), BorderLayout.WEST);
queuePolicyCombo = new JComboBox();
queueStrategy.add(queuePolicyCombo, BorderLayout.CENTER);
queuePolicyPanel.add(queueStrategy, BorderLayout.NORTH);
queueStrategy.setBorder(BorderFactory.createEmptyBorder(2, 5, 10, 5));
queueLengthPanel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
queueLengthPanel.add(infiniteQueueSelector);
queueLengthPanel.add(finiteQueueSelector);
JPanel spinnerPanel = new JPanel();
new BoxLayout(spinnerPanel, BoxLayout.Y_AXIS);
JLabel label = new JLabel("max num.customers: ");
label.setToolTipText("The maximum number of customers allowed in the station.");
spinnerPanel.add(label);
spinnerPanel.add(queueLengthSpinner);
queueLengthPanel.add(spinnerPanel);
this.add(queueLengthPanel, BorderLayout.WEST);
this.add(queuePolicyPanel, BorderLayout.CENTER);
}
示例11: setLowerSpinner
import javax.swing.JSpinner; //导入方法依赖的package包/类
void setLowerSpinner(JSpinner lowerModel) {
lowerSpinner = lowerModel;
lowerModel.setValue(lower);
}
示例12: setUpperSpinner
import javax.swing.JSpinner; //导入方法依赖的package包/类
void setUpperSpinner(JSpinner upperModel) {
upperSpinner = upperModel;
upperModel.setValue(upper);
}