本文整理汇总了Java中javax.swing.SpinnerListModel类的典型用法代码示例。如果您正苦于以下问题:Java SpinnerListModel类的具体用法?Java SpinnerListModel怎么用?Java SpinnerListModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SpinnerListModel类属于javax.swing包,在下文中一共展示了SpinnerListModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SatelliteMultiViewerCorner
import javax.swing.SpinnerListModel; //导入依赖的package包/类
public SatelliteMultiViewerCorner() {
layer = new SpinnerListModel();
layer.addChangeListener(new ChangeListener() {
@SuppressWarnings("rawtypes")
@Override
public void stateChanged(ChangeEvent e) {
// find viewer for satellite
if (layer.getValue() instanceof LayerViewer)
setViewer((LayerViewer) layer.getValue());
else
setViewer(null);
}
});
spinner = new JSpinner(layer);
// Workaround to fix the satellite jumping issue
// caused by changeevent-setviewer-dolayout-setvalue-(layoutinvalid)
spinner.setPreferredSize(new Dimension(105, 22));
getSatellite().getContentPane().add(spinner, BorderLayout.NORTH);
// by default disabled
setEnabled(false);
}
示例2: setBounds
import javax.swing.SpinnerListModel; //导入依赖的package包/类
/**
* Used when a spinne value is updated
*/
private void setBounds() {
double xmin, xmax, ymin, ymax;
Object val;
String val1 = (String) Xmin.getValue();
Vector v = (Vector) ((SpinnerListModel) Xmin.getModel()).getList();
xmin = v.indexOf(val1) + 1;
String val2 = (String) Xmax.getValue();
Vector v2 = (Vector) ((SpinnerListModel) Xmax.getModel()).getList();
xmax = v2.indexOf(val2) + 1;
val = Ymin.getValue();
if (val instanceof Number) {
ymin = ((Number) val).doubleValue();
} else {
ymin = graph.getYRange()[0];
}
val = Ymax.getValue();
if (val instanceof Number) {
ymax = ((Number) val).doubleValue();
} else {
ymax = graph.getYRange()[1];
}
// Sets bounds
graph.setXRange(xmin, xmax);
graph.setYRange(ymin, ymax);
graph.repaint();
}
示例3: createPanel3
import javax.swing.SpinnerListModel; //导入依赖的package包/类
private JPanel createPanel3()
{
JPanel panel = new JPanel(new BorderLayout());
this.spinnerState3 = new JCheckBox("Enabled", true);
this.spinnerState3.setActionCommand("COMBO_STATE3");
this.spinnerState3.addActionListener(this);
panel.add(this.spinnerState3, BorderLayout.EAST);
JPanel controlPanel = new JPanel();
controlPanel.setBorder(BorderFactory.createTitledBorder("List Spinner: "));
this.spinner5 = new JSpinner(new SpinnerListModel(new Object[] {"Red",
"Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"}));
this.spinner6 = new JSpinner(new SpinnerListModel(new Object[] {"Red",
"Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"}));
this.spinner6.setValue("Yellow");
this.spinner6.setFont(new Font("Dialog", Font.PLAIN, 20));
controlPanel.add(this.spinner5);
controlPanel.add(this.spinner6);
panel.add(controlPanel);
return panel;
}
示例4: main
import javax.swing.SpinnerListModel; //导入依赖的package包/类
public static void main(String[] args) {
JFrame jf = new JFrame("It Spins");
Container cp = jf.getContentPane();
cp.setLayout(new GridLayout(0,1));
// Create a JSpinner using one of the pre-defined SpinnerModels
JSpinner dates = new JSpinner(new SpinnerDateModel());
cp.add(dates);
// Create a JSPinner using a SpinnerListModel.
String[] data = { "One", "Two", "Three" };
JSpinner js = new JSpinner(new SpinnerListModel(data));
cp.add(js);
jf.setSize(100, 80);
jf.setVisible(true);
}
示例5: createPanel3
import javax.swing.SpinnerListModel; //导入依赖的package包/类
private JPanel createPanel3()
{
JPanel panel = new JPanel(new BorderLayout());
this.spinnerState3 = new JCheckBox("Enabled", true);
this.spinnerState3.setActionCommand("COMBO_STATE3");
this.spinnerState3.addActionListener(this);
panel.add(this.spinnerState3, BorderLayout.EAST);
JPanel controlPanel = new JPanel();
controlPanel.setBorder(BorderFactory.createTitledBorder("List Spinner: "));
this.spinner5 = new JSpinner(new SpinnerListModel(new Object[] {"Red",
"Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"}));
this.spinner6 = new JSpinner(new SpinnerListModel(new Object[] {"Red",
"Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"}));
this.spinner6.setValue("Yellow");
this.spinner6.setFont(new Font("Dialog", Font.PLAIN, 20));
controlPanel.add(this.spinner5);
controlPanel.add(this.spinner6);
panel.add(controlPanel);
return panel;
}
示例6: BoardSettingPanel
import javax.swing.SpinnerListModel; //导入依赖的package包/类
public BoardSettingPanel() {
int[] boardSizeArray = {9, 13, 19};
ArrayList<Integer> boardSizeList = arrayToList(boardSizeArray);
int[] handicapArray = {0, 2, 3, 4, 5, 6, 7, 8, 9};
ArrayList<Integer> handicapList = arrayToList(handicapArray);
boardSizeModel = new SpinnerListModel(boardSizeList);
handicapModel = new SpinnerListModel(handicapList);
komiModel = new SpinnerNumberModel(6.5, -100.0, 100.0, 0.5);
initComponents();
boardSizeLabel.setText(BOARDSIZE);
handicapLabel.setText(HANDICAP);
komiLabel.setText(KOMI);
boardSizeSpinner.setModel(boardSizeModel);
handicapSpinner.setModel(handicapModel);
komiSpinner.setModel(komiModel);
boardSizeSpinner.setValue(new Integer(19));
}
示例7: NewGameTreePanel
import javax.swing.SpinnerListModel; //导入依赖的package包/类
public NewGameTreePanel() {
int[] boardSizeArray = {9, 13, 19};
ArrayList<Integer> boardSizeList = arrayToList(boardSizeArray);
int[] handicapArray = {0, 2, 3, 4, 5, 6, 7, 8, 9};
ArrayList<Integer> handicapList = arrayToList(handicapArray);
boardSizeModel = new SpinnerListModel(boardSizeList);
handicapModel = new SpinnerListModel(handicapList);
komiModel = new SpinnerNumberModel(6.5, -100.0, 100.0, 0.5);
initComponents();
boardSizeSpinner.setModel(boardSizeModel);
handicapSpinner.setModel(handicapModel);
komiSpinner.setModel(komiModel);
boardSizeSpinner.setValue(new Integer(19));
handicapCheckBox.setSelected(true);
komiCheckBox.setSelected(true);
}
示例8: createListSpinner
import javax.swing.SpinnerListModel; //导入依赖的package包/类
private JSpinner createListSpinner() {
String[] monthStrings = { "January", "February", "March", "April" };
SpinnerListModel spinnerListModel = new SpinnerListModel(monthStrings);
JSpinner listSpinner = new JSpinner(spinnerListModel);
listSpinner.setName("list-spinner");
return listSpinner;
}
示例9: getMinimum
import javax.swing.SpinnerListModel; //导入依赖的package包/类
/**
* Returns a minimal value. Returns null if model is not one of the
* following: {@code javax.swing.SpinnerDateModel},
* {@code javax.swing.SpinnerListModel},
* {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
* model does not have a minimal value.
*
* @return a minimal value.
*/
public Object getMinimum() {
SpinnerModel model = getModel();
if (model instanceof SpinnerNumberModel) {
return ((SpinnerNumberModel) model).getMinimum();
} else if (model instanceof SpinnerDateModel) {
return ((SpinnerDateModel) model).getEnd();
} else if (model instanceof SpinnerListModel) {
List<?> list = ((SpinnerListModel) model).getList();
return list.get(list.size() - 1);
} else {
return null;
}
}
示例10: getMaximum
import javax.swing.SpinnerListModel; //导入依赖的package包/类
/**
* Returns a maximal value. Returns null if model is not one of the
* following: {@code javax.swing.SpinnerDateModel},
* {@code javax.swing.SpinnerListModel},
* {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
* model does not have a maximal value.
*
* @return a maximal value.
*/
public Object getMaximum() {
SpinnerModel model = getModel();
if (model instanceof SpinnerNumberModel) {
return ((SpinnerNumberModel) model).getMaximum();
} else if (model instanceof SpinnerDateModel) {
return ((SpinnerDateModel) model).getEnd();
} else if (model instanceof SpinnerListModel) {
List<?> list = ((SpinnerListModel) model).getList();
return list.get(list.size() - 1);
} else {
return null;
}
}
示例11: IntegerListSpinner
import javax.swing.SpinnerListModel; //导入依赖的package包/类
/**
* Creates a new IntegerListSpinner object.
*/
public IntegerListSpinner ()
{
setModel(new SpinnerListModel());
// Right alignment
JSpinner.DefaultEditor editor;
editor = (JSpinner.DefaultEditor) getEditor();
editor.getTextField().setHorizontalAlignment(JTextField.RIGHT);
}
示例12: setList
import javax.swing.SpinnerListModel; //导入依赖的package包/类
/**
* Assign the List model (for a list-based spinner)
*
* @param spinner the spinner to update
* @param values the model list values
*/
public static void setList (JSpinner spinner,
List<?> values)
{
SpinnerModel model = spinner.getModel();
if (model instanceof SpinnerListModel) {
((SpinnerListModel) model).setList(values);
} else {
throw new IllegalArgumentException("Spinner model is not a SpinnerListModel");
}
}
示例13: TemplateBoard
import javax.swing.SpinnerListModel; //导入依赖的package包/类
/**
* Creates a new {@code TemplateBoard} object.
*
* @param sheet related sheet
* @param table the table of distances
* @param templateService template bus
*/
public TemplateBoard (Sheet sheet,
DistanceTable table,
SelectionService templateService)
{
super(Board.TEMPLATE, sheet.getLocationService(), eventsRead, true, false, false, false);
this.sheet = sheet;
this.table = table;
this.templateService = templateService;
// Shape spinner
shapeSpinner = new JSpinner(
new SpinnerListModel(new ArrayList<Shape>(ShapeSet.TemplateNotes)));
shapeSpinner.addChangeListener(this);
shapeSpinner.setName("shapeSpinner");
shapeSpinner.setToolTipText("Selection of template shape");
// Anchor spinner (with only relevant anchor values for templates)
anchorSpinner = new JSpinner(
new SpinnerListModel(
Arrays.asList(Anchor.LEFT_STEM, Anchor.RIGHT_STEM, Anchor.MIDDLE_LEFT)));
anchorSpinner.addChangeListener(this);
anchorSpinner.setName("anchorSpinner");
anchorSpinner.setToolTipText("Selection of template anchor");
// Eval field
evalField.setEditable(false);
evalField.setHorizontalAlignment(JTextField.CENTER);
evalField.setToolTipText("Matching grade");
defineLayout();
}
示例14: createEditor
import javax.swing.SpinnerListModel; //导入依赖的package包/类
@Override
protected JComponent createEditor(SpinnerModel model) {
if (model instanceof SpinnerDateModel) {
return new DateEditor(this);
} else if (model instanceof SpinnerNumberModel) {
return new NumberEditor(this);
} else if (model instanceof SpinnerListModel) {
return new ListEditor(this);
} else if (model instanceof SpinnerIntModel) {
return new IntegerEditor(this);
} else {
return new DefaultEditor(this);
}
}
示例15: createDemo
import javax.swing.SpinnerListModel; //导入依赖的package包/类
/** Create a minimal demo for the javadoc. */
public static JSpinner createDemo(boolean useNumbers) {
JSpinner spinner;
if(useNumbers) {
spinner = new JSpinner(new SpinnerNumberModel(5,1,10,1));
} else {
spinner = new JSpinner(new SpinnerListModel(new Object[] {"Red", "Green", "Blue"}));
}
spinner.setUI(new LargeNavigationPanelUI());
spinner.setBorder(new EmptyBorder(5,5,5,5));
return spinner;
}