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


Java SpinnerNumberModel类代码示例

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


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

示例1: init

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
/**
 * Initialization.
 */
private void init() {
    Dimension dim = getToolkit().getScreenSize();
    this.setLocation(dim.width / 2 - this.getWidth() / 2, dim.height / 2 - this.getHeight() / 2);
    try {
        this.setTitle(Translator.translate("Attack", LANG, false));
    } catch (TranslationException ex) {
        this.setTitle("");
    }

    AttackerDialog attackerDialog = this;
    attackerArmies.setModel(new SpinnerNumberModel(1, 1, 1, 1));

    declare.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PlayAudio.play("src/resources/sounds/tank.wav");
            game.setAttackerArmies((int) attackerArmies.getValue());
            attackerDialog.setVisible(false);
            game.declareAttack();
        }
    });

}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:27,代码来源:AttackerDialog.java

示例2: ControlsPanel

import javax.swing.SpinnerNumberModel; //导入依赖的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");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:MultiGradientTest.java

示例3: changeZoom

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
/**
 * Changes the zoom level
 * @param delta How much to change the current level (can be negative or
 * positive)
 */
public void changeZoom(int delta) {	
	SpinnerNumberModel model = 
		(SpinnerNumberModel)this.zoomSelector.getModel();
	double curZoom = model.getNumber().doubleValue();
	Number newValue = new Double(curZoom + model.getStepSize().
			doubleValue() * delta * curZoom * 100); 
	
	if (newValue.doubleValue() < ZOOM_MIN) {
		newValue = ZOOM_MIN;
	} else if (newValue.doubleValue() > ZOOM_MAX) {
		newValue = ZOOM_MAX;
	}

	model.setValue(newValue);
	this.updateZoomScale(true);
}
 
开发者ID:MaX121,项目名称:Bachelor-Thesis,代码行数:22,代码来源:GUIControls.java

示例4: initComponents

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
private void initComponents() {
	this.setLayout(new BorderLayout());
	epochs = new JSpinner(new SpinnerNumberModel(10, 10, 50, 1));
	JPanel epochOption = new JPanel(new BorderLayout());
	JPanel flowTemp = new JPanel(new FlowLayout(FlowLayout.LEFT));
	epochs.setPreferredSize(new Dimension(70, 40));
	epochs.setFont(new Font(epochs.getFont().getName(), epochs.getFont().getStyle(), epochs.getFont().getSize() + 4));
	flowTemp.add(new JLabel("<html><body><h3>Select the maximum number of epochs: </h3></body></html> "));
	flowTemp.add(epochs);
	JButton setEpoch = new JButton(this.setEpoch);
	setEpoch.setPreferredSize(new Dimension(85, 35));
	flowTemp.add(setEpoch);
	epochOption.add(flowTemp, BorderLayout.CENTER);
	//JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
	//btnPanel.add(setEpoch);
	//epochOption.add(btnPanel,BorderLayout.SOUTH);
	this.add(epochOption, BorderLayout.NORTH);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:19,代码来源:EpochPanel.java

示例5: configureSize

import javax.swing.SpinnerNumberModel; //导入依赖的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

示例6: JLongSpinner

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
/**
 * Constructs a new {@code JLongSpinner}.
 */
public JLongSpinner() {
    super(new SpinnerNumberModel((Long) 0L, (Long) DEFAULT_MIN_VALUE, (Long) DEFAULT_MAX_VALUE,
            (Long) DEFAULT_STEP_SIZE));

    this.minValue = DEFAULT_MIN_VALUE;
    this.maxValue = DEFAULT_MAX_VALUE;

    final JSpinner.NumberEditor editor = new JSpinner.NumberEditor(this);
    editor.getFormat().setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
    setEditor(editor);

    final Dimension minimumSize = getMinimumSize();
    minimumSize.width = SPINNER_WIDTH;
    setMinimumSize(minimumSize);

    final Dimension preferredSize = getPreferredSize();
    preferredSize.width = SPINNER_WIDTH;
    setPreferredSize(preferredSize);
}
 
开发者ID:FWDekker,项目名称:intellij-randomness,代码行数:23,代码来源:JLongSpinner.java

示例7: IntegerOptionUI

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
/**
 * Creates a new {@code IntegerOptionUI} for the given
 * {@code IntegerOption}.
 *
 * @param option The {@code IntegerOption} to make a user interface for.
 * @param editable boolean whether user can modify the setting
 */
public IntegerOptionUI(final IntegerOption option, boolean editable) {
    super(option, editable);

    final int value = option.getValue();
    int min = option.getMinimumValue();
    int max = option.getMaximumValue();
    if (min > max) {
        int tmp = min;
        min = max;
        max = tmp;
    }
    final int stepSize = Math.max(1, Math.min((max - min) / 10, 1000));
    this.spinner.setModel(new SpinnerNumberModel(value, min, max, 1));
    initialize();
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:23,代码来源:IntegerOptionUI.java

示例8: init

import javax.swing.SpinnerNumberModel; //导入依赖的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);
}
 
开发者ID:etomica,项目名称:etomica,代码行数:18,代码来源:DeviceSpinner.java

示例9: intValue

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
/**
 * Prompts the user for int value
 * 
 * @param name The name of the dialog to show
 * @param currentValue The current value to be displayed
 * @param description The help text to provide
 * @return The value selected by the user
 */
static public Value intValue (String name, final int currentValue, final String description) {
	return new DefaultValue(name, String.valueOf(currentValue)) {
		public void showDialog () {
			JSpinner spinner = new JSpinner(new SpinnerNumberModel(currentValue, Short.MIN_VALUE, Short.MAX_VALUE, 1));
			if (showValueDialog(spinner, description)) value = String.valueOf(spinner.getValue());
		}

		public Object getObject () {
			return Integer.valueOf(value);
		}
	};
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:21,代码来源:EffectUtil.java

示例10: floatValue

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
/**
 * Prompts the user for float value
 * 
 * @param name The name of the dialog to show
 * @param currentValue The current value to be displayed
 * @param description The help text to provide
 * @param min The minimum value to allow
 * @param max The maximum value to allow
 * @return The value selected by the user
 */
static public Value floatValue (String name, final float currentValue, final float min, final float max,
	final String description) {
	return new DefaultValue(name, String.valueOf(currentValue)) {
		public void showDialog () {
			JSpinner spinner = new JSpinner(new SpinnerNumberModel(currentValue, min, max, 0.1f));
			if (showValueDialog(spinner, description)) value = String.valueOf(((Double)spinner.getValue()).floatValue());
		}

		public Object getObject () {
			return Float.valueOf(value);
		}
	};
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:24,代码来源:EffectUtil.java

示例11: updateZoomScale

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
/**
 * Updates zoom scale to the one selected by zoom chooser
 * @param centerView If true, the center of the viewport should remain
 * the same
 */
private void updateZoomScale(boolean centerView) {
	double scale = ((SpinnerNumberModel)zoomSelector.getModel()).
		getNumber().doubleValue();
	
	if (centerView) {
		Coord center = gui.getCenterViewCoord();
		this.pf.setScale(scale);
		gui.centerViewAt(center);
	}
	else {
		this.pf.setScale(scale);
	}
}
 
开发者ID:MaX121,项目名称:Bachelor-Thesis,代码行数:19,代码来源:GUIControls.java

示例12: WidthHeightPanel

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
WidthHeightPanel(boolean showWidth, boolean showHeight) {
    ResourceBundle bundle = NbBundle.getBundle(BoxFillerInitializer.class);
    JLabel widthLabel = new JLabel(bundle.getString("BoxFillerInitializer.width")); // NOI18N
    JLabel heightLabel = new JLabel(bundle.getString("BoxFillerInitializer.height")); // NOI18N
    widthField = new JSpinner(new SpinnerNumberModel());
    heightField = new JSpinner(new SpinnerNumberModel());
    GroupLayout layout = new GroupLayout(this);
    setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                .addComponent(widthLabel)
                .addComponent(heightLabel))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addComponent(widthField)
                .addComponent(heightField))
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(widthLabel)
                .addComponent(widthField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(heightLabel)
                .addComponent(heightField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    widthLabel.setVisible(showWidth);
    heightLabel.setVisible(showHeight);
    widthField.setVisible(showWidth);
    heightField.setVisible(showHeight);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:BoxFillerInitializer.java

示例13: updateModel

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
@Override
protected void updateModel() {
   XMLContentAttributes contentAttr = new XMLContentAttributes(model.getPrefix());
   contentAttr.setOptionalAttributes(attributes.isSelected());
   contentAttr.setOptionalElements(elements.isSelected());
   
   contentAttr.setPreferredOccurences(((SpinnerNumberModel)occurSpinner.getModel()).getNumber().intValue());
   contentAttr.setDepthPreferrence(((SpinnerNumberModel)depthSpinner.getModel()).getNumber().intValue());
   
   model.setXMLContentAttributes(contentAttr);
   if(visible) {
       Object root = rootElementComboBox.getSelectedItem();
       model.setRoot(root == null ? null : root.toString());
   }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:XMLContentPanel.java

示例14: initView

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
@Override
protected void initView() {
   attributes.setSelected(true);
   elements.setSelected(true);
   
   occurencesModel = new SpinnerNumberModel(3, 0, 10, 1);
   occurSpinner.setModel(occurencesModel);
   
   depthModel = new SpinnerNumberModel(2, 0, 10, 1);
   depthSpinner.setModel(depthModel);
   
    rootModel = new DefaultComboBoxModel();
    rootElementComboBox.setModel(rootModel);       
    
    if(getSchemaInfo() == null)
        return;
    
    if(schemaInfo.roots.size() ==0){
        //TODO: should have some error message
        //String errMsg =  NbBundle.getMessage(XMLContentPanel.class, "MSG_XMLContentPanel_No_Root");
        //templateWizard.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, errMsg);
        return;
    }
    Iterator it = schemaInfo.roots.iterator();
        while (it.hasNext()) {
             String next = (String) it.next();
             rootModel.addElement(next);
        }    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:XMLContentPanel.java

示例15: defaultHeight

import javax.swing.SpinnerNumberModel; //导入依赖的package包/类
private static int defaultHeight() {
    if (DEFAULT_HEIGHT == -1) {
        JPanel ref = new JPanel(null);
        ref.setLayout(new BoxLayout(ref, BoxLayout.LINE_AXIS));
        ref.setOpaque(false);
        
        ref.add(new JLabel("XXX")); // NOI18N
        
        ref.add(new JButton("XXX")); // NOI18N
        ref.add(new PopupButton("XXX")); // NOI18N
        
        ref.add(new JCheckBox("XXX")); // NOI18N
        ref.add(new JRadioButton("XXX")); // NOI18N
        
        ref.add(new JTextField("XXX")); // NOI18N
        
        ref.add(new JExtendedSpinner(new SpinnerNumberModel(1, 1, 655535, 1)));
        
        Component separator = Box.createHorizontalStrut(1);
        Dimension d = separator.getMaximumSize(); d.height = 20;
        separator.setMaximumSize(d);
        ref.add(separator);
        
        DEFAULT_HEIGHT = ref.getPreferredSize().height;
    }
    return DEFAULT_HEIGHT;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:SettingsPanel.java


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