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


Java JSpinner.getValue方法代码示例

本文整理汇总了Java中javax.swing.JSpinner.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java JSpinner.getValue方法的具体用法?Java JSpinner.getValue怎么用?Java JSpinner.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JSpinner的用法示例。


在下文中一共展示了JSpinner.getValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureSize

import javax.swing.JSpinner; //导入方法依赖的package包/类
/**
 * Shows the size configuration dialog
 */
protected static final void configureSize(){
	JPanel pconfig = new JPanel(new BorderLayout());
	JSpinner s = new JSpinner(new SpinnerNumberModel(config.size * 100, 50, Integer.MAX_VALUE, 1));
	JLabel info = new JLabel("<html>Change how big the displayed window is.<br>"
			+ "The precentage specifies how big the window is in<br>"
			+ "comparison to the default size of the window.<html>");
	pconfig.add(info, BorderLayout.PAGE_START);
	pconfig.add(new JSeparator(), BorderLayout.CENTER);
	JPanel line = new JPanel();
	line.add(new JLabel("Size: "));
	line.add(s);
	line.add(new JLabel("%"));
	pconfig.add(line, BorderLayout.PAGE_END);
	if(0 == JOptionPane.showOptionDialog(null, pconfig, "Keys per second", 0, JOptionPane.QUESTION_MESSAGE, null, new String[]{"OK", "Cancel"}, 0)){
		config.size = ((double)s.getValue()) / 100.0D;
	}
}
 
开发者ID:RoanH,项目名称:KeysPerSecond,代码行数:21,代码来源:Main.java

示例2: select

import javax.swing.JSpinner; //导入方法依赖的package包/类
/**
 * If the spinner's editor is a DateEditor, this selects the field
 * associated with the value that is being incremented.
 */
private void select(JSpinner spinner)
{
	JComponent editor = spinner.getEditor();

	if( editor instanceof JSpinner.DateEditor )
	{
		JSpinner.DateEditor dateEditor = (JSpinner.DateEditor) editor;
		JFormattedTextField ftf = dateEditor.getTextField();
		Format format = dateEditor.getFormat();
		Object value = spinner.getValue();

		if( format != null && value != null )
		{
			SpinnerDateModel model = dateEditor.getModel();
			DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField());

			if( field != null )
			{
				try
				{
					AttributedCharacterIterator iterator = format.formatToCharacterIterator(value);
					if( !select(ftf, iterator, field) && field == DateFormat.Field.HOUR0 )
					{
						select(ftf, iterator, DateFormat.Field.HOUR1);
					}
				}
				catch( IllegalArgumentException iae )
				{
					// ??
				}
			}
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:39,代码来源:FlatterSpinnerUI.java

示例3: 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


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