本文整理汇总了Java中javax.swing.JSpinner.setModel方法的典型用法代码示例。如果您正苦于以下问题:Java JSpinner.setModel方法的具体用法?Java JSpinner.setModel怎么用?Java JSpinner.setModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JSpinner
的用法示例。
在下文中一共展示了JSpinner.setModel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDateSpinner
import javax.swing.JSpinner; //导入方法依赖的package包/类
static void createDateSpinner() {
Calendar calendar = Calendar.getInstance();
Date initDate = calendar.getTime();
calendar.add(Calendar.YEAR, -1);
Date earliestDate = calendar.getTime();
calendar.add(Calendar.YEAR, 1);
Date latestDate = calendar.getTime();
SpinnerModel dateModel = new SpinnerDateModel(initDate,
earliestDate,
latestDate,
Calendar.YEAR);
spinner = new JSpinner();
spinner.setModel(dateModel);
}
示例2: ZoomControl
import javax.swing.JSpinner; //导入方法依赖的package包/类
public ZoomControl(ZoomModel model) {
super(new BorderLayout());
this.model = model;
spinnerModel = new SpinnerModel();
spinner = new JSpinner();
spinner.setModel(spinnerModel);
this.add(spinner, BorderLayout.CENTER);
grid = new GridIcon();
this.add(grid, BorderLayout.EAST);
grid.update();
model.addPropertyChangeListener(ZoomModel.SHOW_GRID, grid);
model.addPropertyChangeListener(ZoomModel.ZOOM, spinnerModel);
}
示例3: initProperties
import javax.swing.JSpinner; //导入方法依赖的package包/类
@Override
protected void initProperties() {
setTitle("Friend area editor");
// Initialize the components
lblName = new JLabel("Name");
lblNamePointer = new JLabel("Name pointer");
lblCount = new JLabel("No. of Pokémon");
lblCondition = new JLabel("Unlock condition");
lblPrice = new JLabel("Price");
txtName = new JTextField("00000000");
txtName.setEditable(false);
txtNamePointer = new JTextField();
txtNamePointer.setEditable(false);
spnCount = new JSpinner();
spnCount.setModel(new SpinnerNumberModel(0, 0, 15, 1));
cmoCondition = new JComboBox();
cmoCondition.setModel(new DefaultComboBoxModel(new String[] { "0x0: Shop (Story-game)", "0x1: Shop (Post-game)", "0x2: Wonder mail event", "0x3: Legendary request" }));
spnPrice = new JSpinner();
spnPrice.setModel(new SpinnerNumberModel(Long.valueOf(0L), Long.valueOf(0L), Long.valueOf(99999L), Long.valueOf(1L)));
// Add the components to the property panel
properties.addCaption("Area settings");
properties.addLabeledComponent(lblName, txtName);
properties.addLabeledComponent(lblNamePointer, txtNamePointer);
properties.addLabeledComponent(lblCount, spnCount);
properties.addLabeledComponent(lblCondition, cmoCondition);
properties.addLabeledComponent(lblPrice, spnPrice);
properties.addTerminator();
}
示例4: bug6463712
import javax.swing.JSpinner; //导入方法依赖的package包/类
public bug6463712() {
SpinnerNumberModel m1 = new SpinnerNumberModel();
JSpinner s = new JSpinner(m1);
s.addChangeListener(this);
SpinnerDateModel m2 = new SpinnerDateModel();
s.setModel(m2);
// m1 is no longer linked to the JSpinner (it has been replaced by m2), so
// the following should not trigger a call to our stateChanged() method...
m1.setValue(new Integer(1));
}
示例5: createNumberSpinner
import javax.swing.JSpinner; //导入方法依赖的package包/类
static void createNumberSpinner() {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.YEAR, -1);
calendar.add(Calendar.YEAR, 1);
int currentYear = calendar.get(Calendar.YEAR);
SpinnerModel yearModel = new SpinnerNumberModel(currentYear, //initial value
currentYear - 1, //min
currentYear + 2, //max
1); //step
spinner = new JSpinner();
spinner.setModel(yearModel);
}
示例6: DecorMobPanel
import javax.swing.JSpinner; //导入方法依赖的package包/类
/**
* Create the panel.
*/
public DecorMobPanel() {
TitledBorder border = new TitledBorder(new LineBorder(new Color(128, 128, 128)), Resources.get("panel_decorMob"), TitledBorder.LEADING, TitledBorder.TOP, null, null);
border.setTitleFont(border.getTitleFont().deriveFont(Font.BOLD));
setBorder(border);
JLabel lblSprite = new JLabel(Resources.get("panel_sprite"));
comboBoxSpriteSheets = new JComboBox<>();
comboBoxSpriteSheets.setRenderer(new MyComboRenderer());
JLabel lblBehaviour = new JLabel(Resources.get("panel_behavior"));
comboBoxBehaviour = new JComboBox<>();
comboBoxBehaviour.setModel(new DefaultComboBoxModel<MovementBehavior>(MovementBehavior.values()));
lblVvelocity = new JLabel(Resources.get("panel_velocity"));
spinnerVelocity = new JSpinner();
spinnerVelocity.setModel(new SpinnerNumberModel(0, 0, 100, 1));
chckbxAttackable = new JCheckBox(Resources.get("panel_attackable"));
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblSprite, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(comboBoxSpriteSheets, 0, 95, Short.MAX_VALUE)
.addGap(10))
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblBehaviour, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(comboBoxBehaviour, 0, 95, Short.MAX_VALUE)
.addContainerGap())
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblVvelocity, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(chckbxAttackable, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(28))
.addComponent(spinnerVelocity, GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE))
.addContainerGap()))));
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(lblSprite, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addComponent(comboBoxSpriteSheets, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblBehaviour, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addComponent(comboBoxBehaviour, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblVvelocity, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerVelocity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(chckbxAttackable)
.addContainerGap(171, Short.MAX_VALUE)));
setLayout(groupLayout);
this.setupChangedListeners();
}
示例7: PropPanel
import javax.swing.JSpinner; //导入方法依赖的package包/类
/**
* Create the panel.
*/
public PropPanel() {
TitledBorder border = new TitledBorder(new LineBorder(new Color(128, 128, 128)), Resources.get("panel_prop"), TitledBorder.LEADING, TitledBorder.TOP, null, null);
border.setTitleFont(border.getTitleFont().deriveFont(Font.BOLD));
setBorder(border);
JLabel lblHealth = new JLabel(Resources.get("panel_health"));
spinnerHealth = new JSpinner();
spinnerHealth.setModel(new SpinnerNumberModel(100, 0, 1000000, 1));
JLabel lblMaterial = new JLabel(Resources.get("panel_material"));
comboBoxMaterial = new JComboBox<>();
comboBoxMaterial.setModel(new DefaultComboBoxModel<Material>(Material.values()));
JLabel lblSprite = new JLabel(Resources.get("panel_sprite"));
comboBoxSpriteSheets = new JComboBox<>();
comboBoxSpriteSheets.setRenderer(new MyComboRenderer());
chckbxIndestructible = new JCheckBox(Resources.get("panel_destructible"));
chckbxIsObstacle = new JCheckBox(Resources.get("panel_isObstacle"));
chckbxShadow = new JCheckBox("shadow");
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(lblHealth, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
.addComponent(lblMaterial, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
.addComponent(lblSprite, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(chckbxShadow, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
.addComponent(comboBoxMaterial, 0, 365, Short.MAX_VALUE)
.addComponent(spinnerHealth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(comboBoxSpriteSheets, 0, 365, Short.MAX_VALUE)
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING, false)
.addComponent(chckbxIsObstacle, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(chckbxIndestructible, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap()));
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblHealth, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerHealth, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblMaterial, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addComponent(comboBoxMaterial, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(comboBoxSpriteSheets, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(lblSprite, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(chckbxIndestructible)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(chckbxIsObstacle, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(chckbxShadow, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
.addContainerGap(138, Short.MAX_VALUE)));
setLayout(groupLayout);
this.setupChangedListeners();
}
示例8: CollisionPanel
import javax.swing.JSpinner; //导入方法依赖的package包/类
/**
* Create the panel.
*/
public CollisionPanel() {
TitledBorder border = new TitledBorder(new LineBorder(new Color(128, 128, 128)), Resources.get("panel_collisionEntity"), TitledBorder.LEADING, TitledBorder.TOP, null, null);
border.setTitleFont(border.getTitleFont().deriveFont(Font.BOLD));
setBorder(border);
JLabel lblHealth = new JLabel(Resources.get("panel_collision"));
JLabel lblMaterial = new JLabel(Resources.get("panel_width"));
chckbxHasCollision = new JCheckBox(" ");
JLabel lblHeightFactor = new JLabel(Resources.get("panel_height"));
spinnerWidth = new JSpinner();
spinnerWidth.setModel(new SpinnerNumberModel(0, 0, null, 0.5f));
spinnerHeight = new JSpinner();
spinnerHeight.setModel(new SpinnerNumberModel(0, 0, null, 0.5f));
comboBoxAlign = new JComboBox<>();
comboBoxAlign.setModel(new DefaultComboBoxModel<Align>(Align.values()));
comboBoxValign = new JComboBox<>();
comboBoxValign.setModel(new DefaultComboBoxModel<Valign>(Valign.values()));
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblHealth, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(chckbxHasCollision))
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblMaterial, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(spinnerWidth))
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblHeightFactor)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(spinnerHeight, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(comboBoxAlign, 0, 53, Short.MAX_VALUE)
.addComponent(comboBoxValign, 0, 53, Short.MAX_VALUE))
.addContainerGap()));
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblHealth, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addComponent(chckbxHasCollision))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblMaterial, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerWidth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(comboBoxAlign, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblHeightFactor, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerHeight, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(comboBoxValign, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
setLayout(groupLayout);
this.setupChangedListeners();
}