本文整理汇总了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;
}
}
示例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 )
{
// ??
}
}
}
}
}
示例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;
}
}