當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。