当前位置: 首页>>代码示例>>Java>>正文


Java JSpinner.setValue方法代码示例

本文整理汇总了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);
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:30,代码来源:TimeoutValueHandlerTest.java

示例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()); 
	
}
 
开发者ID:fossasia,项目名称:zooracle,代码行数:13,代码来源:ComparePanel.java

示例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);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:39,代码来源:IterationSelector.java

示例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);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:41,代码来源:InputSectionPanel.java

示例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);
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:38,代码来源:FlatterSpinnerUI.java

示例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;
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:31,代码来源:DavisUserControlPanel.java

示例7: setupInstance

import javax.swing.JSpinner; //导入方法依赖的package包/类
protected void setupInstance(JSpinner instance) {
    super.setupInstance(instance);
    
    if (value != null) instance.setValue(value);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:JComponentBuilders.java

示例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);
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:55,代码来源:TimeoutValueHandlerTest.java

示例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);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:54,代码来源:FuzzyInfoClustering.java

示例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);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:43,代码来源:InputSectionPanel.java

示例11: setLowerSpinner

import javax.swing.JSpinner; //导入方法依赖的package包/类
void setLowerSpinner(JSpinner lowerModel) {
  lowerSpinner = lowerModel;
  lowerModel.setValue(lower);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:5,代码来源:BoundSelectionPage.java

示例12: setUpperSpinner

import javax.swing.JSpinner; //导入方法依赖的package包/类
void setUpperSpinner(JSpinner upperModel) {
  upperSpinner = upperModel;
  upperModel.setValue(upper);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:5,代码来源:BoundSelectionPage.java


注:本文中的javax.swing.JSpinner.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。