javax.swing.SpinnerNumberModel Java Examples
The following examples show how to use
javax.swing.SpinnerNumberModel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JColorPicker.java From pumpernickel with MIT License | 6 votes |
public Option(String text, int max) { spinner = new JSpinner(new SpinnerNumberModel(0, 0, max, 5)); spinner.addChangeListener(changeListener); /* * this tries out Tim Boudreaux's new slider UI. It's a good UI, but * I think for the JColorPicker the numeric controls are more * useful. That is: users who want click-and-drag control to choose * their colors don't need any of these Option objects at all; only * power users who may have specific RGB values in mind will use * these controls: and when they do limiting them to a slider is * unnecessary. That's my current position... of course it may not * be true in the real world... :) */ // slider = new JSlider(0,max); // slider.addChangeListener(changeListener); // slider.setUI(new // org.netbeans.paint.api.components.PopupSliderUI()); label = new JLabel(text); radioButton.addActionListener(actionListener); }
Example #2
Source File: PixelExtractionParametersForm.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private Component[] createTimeDeltaComponents(TableLayout tableLayout) { final JLabel boxLabel = new JLabel("Allowed time difference:"); timeBox = new JCheckBox("Use time difference constraint"); final Component horizontalSpacer = tableLayout.createHorizontalSpacer(); final Component horizontalSpacer2 = tableLayout.createHorizontalSpacer(); timeSpinner = new JSpinner(new SpinnerNumberModel(1, 1, null, 1)); timeSpinner.setEnabled(false); timeUnitComboBox = new JComboBox<>(new String[]{"Day(s)", "Hour(s)", "Minute(s)"}); timeUnitComboBox.setEnabled(false); timeBox.addActionListener(e -> { timeSpinner.setEnabled(timeBox.isSelected()); timeUnitComboBox.setEnabled(timeBox.isSelected()); }); return new Component[]{boxLabel, timeBox, horizontalSpacer, horizontalSpacer2, timeSpinner, timeUnitComboBox}; }
Example #3
Source File: MultiGradientTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example #4
Source File: GlyphsFrame.java From constellation with Apache License 2.0 | 6 votes |
private void fontActionPerformed() { final FontInfo[] fontsInfo = glyphManager.getFonts(); final String fontName = (String) fontNameSp.getSelectedItem(); final int fontStyle = cbBold.isSelected() ? Font.BOLD : Font.PLAIN; final int fontSize = ((SpinnerNumberModel) fontSizeSp.getModel()).getNumber().intValue(); final FontInfo fi = fontsInfo[0]; fontsInfo[0] = new FontInfo(fontName, fontStyle, fontSize, fi.mustHave, fi.mustNotHave); glyphManager.setFonts(fontsInfo); glyphManager.createBackgroundGlyph(0.5f); showTextureBuffer(); final String line = getLine(); glyphManager.renderTextAsLigatures(line, null); repaint(); }
Example #5
Source File: CgSpinner.java From Course_Generator with GNU General Public License v3.0 | 6 votes |
public CgSpinner(int start, int min, int max, int step) { super(); this.min = min; this.max = max; this.step = step; model = new SpinnerNumberModel(start, // initial value min, // min max, // max step); // step setModel(model); addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent mwe) { MouseWheelAction(mwe.getWheelRotation()); } }); // Center JSpinner.DefaultEditor spinnerEditor = (JSpinner.DefaultEditor) this.getEditor(); spinnerEditor.getTextField().setHorizontalAlignment(JTextField.CENTER); }
Example #6
Source File: CgSpinnerDouble.java From Course_Generator with GNU General Public License v3.0 | 6 votes |
public CgSpinnerDouble(double start, double min, double max, double step) { super(); this.min = min; this.max = max; this.step = step; model = new SpinnerNumberModel(start, // initial value min, // min max, // max step); this.setModel(model); addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent mwe) { MouseWheelAction(mwe.getWheelRotation()); } }); // Center JSpinner.DefaultEditor spinnerEditor = (JSpinner.DefaultEditor) this.getEditor(); spinnerEditor.getTextField().setHorizontalAlignment(JTextField.CENTER); }
Example #7
Source File: SpinnerRangeDouble.java From DeconvolutionLab2 with GNU General Public License v3.0 | 6 votes |
/** * Constructor. */ public SpinnerRangeDouble(double defValue, double minValue, double maxValue, double incValue, String format) { super(); this.defValue = defValue; this.minValue = minValue; this.maxValue = maxValue; this.incValue = incValue; Double def = new Double(defValue); Double min = new Double(minValue); Double max = new Double(maxValue); Double inc = new Double(incValue); model = new SpinnerNumberModel(def, min, max, inc); setModel(model); setEditor(new JSpinner.NumberEditor(this, format)); JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField(); tf.setColumns(7); }
Example #8
Source File: AddLayerDialog.java From WorldPainter with GNU General Public License v3.0 | 6 votes |
/** * Creates new form AddLayerDialog */ public AddLayerDialog(Window parent, List<Layer> layers, int maxHeight) { super(parent); this.maxHeight = maxHeight; initComponents(); DefaultComboBoxModel<Layer> comboBoxModel = new DefaultComboBoxModel<>(layers.toArray(new Layer[layers.size()])); comboBoxLayer.setModel(comboBoxModel); comboBoxLayer.setRenderer(new LayerListCellRenderer()); ((SpinnerNumberModel) spinnerFrom.getModel()).setMaximum(maxHeight - 1); spinnerFrom.setValue(maxHeight / 2); ((SpinnerNumberModel) spinnerTo.getModel()).setMaximum(maxHeight - 1); spinnerTo.setValue(maxHeight - 1); setControlStates(); getRootPane().setDefaultButton(buttonOK); scaleToUI(); pack(); setLocationRelativeTo(parent); }
Example #9
Source File: MultiGradientTest.java From hottub with GNU General Public License v2.0 | 6 votes |
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"); }
Example #10
Source File: SpinnerRangeFloat.java From DeconvolutionLab2 with GNU General Public License v3.0 | 6 votes |
/** * Constructor. */ public SpinnerRangeFloat(float defValue, float minValue, float maxValue, float incValue, String format) { super(); this.defValue = defValue; this.minValue = minValue; this.maxValue = maxValue; this.incValue = incValue; Double def = new Double(defValue); Double min = new Double(minValue); Double max = new Double(maxValue); Double inc = new Double(incValue); this.model = new SpinnerNumberModel(def, min, max, inc); setModel(model); setEditor(new JSpinner.NumberEditor(this, format)); JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField(); tf.setColumns(7); }
Example #11
Source File: SpinnerRangeFloat.java From DeconvolutionLab2 with GNU General Public License v3.0 | 6 votes |
/** * Constructor. */ public SpinnerRangeFloat(float defValue, float minValue, float maxValue, float incValue, int visibleChars) { super(); this.defValue = defValue; this.minValue = minValue; this.maxValue = maxValue; this.incValue = incValue; Float def = new Float(defValue); Float min = new Float(minValue); Float max = new Float(maxValue); Float inc = new Float(incValue); model = new SpinnerNumberModel(def, min, max, inc); setModel(model); JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField(); tf.setColumns(visibleChars); }
Example #12
Source File: MultiGradientTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example #13
Source File: SpinnerRangeInteger.java From DeconvolutionLab2 with GNU General Public License v3.0 | 6 votes |
/** * Constructor. */ public SpinnerRangeInteger(int defValue, int minValue, int maxValue, int incValue) { super(); this.defValue = defValue; this.minValue = minValue; this.maxValue = maxValue; this.incValue = incValue; Integer def = new Integer(defValue); Integer min = new Integer(minValue); Integer max = new Integer(maxValue); Integer inc = new Integer(incValue); model = new SpinnerNumberModel(def, min, max, inc); setModel(model); JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField(); tf.setColumns(7); }
Example #14
Source File: MultiGradientTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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"); }
Example #15
Source File: ComboBoxSearchField.java From sc2gears with Apache License 2.0 | 6 votes |
/** * Creates a new ComboBoxSearchField. * @param id id of the search field * @param valueVector vector of values to add to the combo box (null values are not allowed!) */ public ComboBoxSearchField( final Id id, final Vector< Object > valueVector, final boolean showMinOccurence ) { super( id ); comboBox = new JComboBox<>( valueVector ); comboBox.setRenderer( new BaseLabelListCellRenderer< Object >() { @Override public Icon getIcon( final Object value ) { return ComboBoxSearchField.this.getIcon( value ); } } ); comboBox.setPreferredSize( new Dimension( 100, comboBox.getMinimumSize().height ) ); uiComponent.add( comboBox ); if ( showMinOccurence ) { minOccurrenceSpinner = new JSpinner( new SpinnerNumberModel( 1, 1, 999, 1 ) ); uiComponent.add( new JLabel( Language.getText( "module.repSearch.tab.filters.name.minOccurrenceText" ) ) ); minOccurrenceSpinner.setEditor( new JSpinner.NumberEditor( minOccurrenceSpinner ) ); minOccurrenceSpinner.setMaximumSize( new Dimension( 50, minOccurrenceSpinner.getPreferredSize().height ) ); uiComponent.add( minOccurrenceSpinner ); } }
Example #16
Source File: MultiGradientTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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"); }
Example #17
Source File: SpinnerRangeDouble.java From DeconvolutionLab2 with GNU General Public License v3.0 | 6 votes |
/** * Constructor. */ public SpinnerRangeDouble(double defValue, double minValue, double maxValue, double incValue) { super(); this.defValue = defValue; this.minValue = minValue; this.maxValue = maxValue; this.incValue = incValue; Double def = new Double(defValue); Double min = new Double(minValue); Double max = new Double(maxValue); Double inc = new Double(incValue); model = new SpinnerNumberModel(def, min, max, inc); setModel(model); JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField(); tf.setColumns(7); }
Example #18
Source File: NegotiationDialog.java From freecol with GNU General Public License v2.0 | 5 votes |
/** * Creates a new {@code GoldTradeItemPanel} instance. * * @param source The {@code Player} that is trading. * @param gold The maximum amount of gold to trade. */ public GoldTradeItemPanel(Player source, int gold) { super(new MigLayout("wrap 1", "", "")); this.source = source; this.spinner = new JSpinner(new SpinnerNumberModel(0, 0, gold, 1)); JButton clearButton = Utility.localizedButton("negotiationDialog.clear"); clearButton.addActionListener(this); clearButton.setActionCommand(CLEAR); JButton addButton = Utility.localizedButton("negotiationDialog.add"); addButton.addActionListener(this); addButton.setActionCommand(ADD); // adjust entry size ((JSpinner.DefaultEditor)this.spinner.getEditor()) .getTextField() .setColumns(5); setBorder(Utility.SIMPLE_LINE_BORDER); add(Utility.localizedLabel(Messages.getName("model.tradeItem.gold"))); add(Utility.localizedLabel(StringTemplate .template("negotiationDialog.goldAvailable") .addAmount("%amount%", gold))); add(this.spinner); add(clearButton, "split 2"); add(addButton); setSize(getPreferredSize()); }
Example #19
Source File: HarrisPointsDemo.java From COMP3204 with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public JPanel getComponent(int width, int height) throws IOException { final JPanel c = super.getComponent(width, height); this.vc.getDisplay().addVideoListener(this); final JPanel controls = new JPanel(new GridBagLayout()); controls.setOpaque(false); windowSizeSpinner = new JSpinner(new SpinnerNumberModel(21, 7, 31, 2)); ((JSpinner.NumberEditor) windowSizeSpinner.getEditor()).getTextField().setFont(FONT); final JLabel lbl = new JLabel("Window Size (pixels): "); lbl.setFont(FONT); controls.add(lbl); controls.add(windowSizeSpinner); thresholdSpinner = new JSlider(0, 100); final JLabel lbl2 = new JLabel(" Threshold: "); lbl2.setFont(FONT); controls.add(lbl2); controls.add(thresholdSpinner); final GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 1; c.add(controls, gbc); return c; }
Example #20
Source File: AddTerrainRangeDialog.java From WorldPainter with GNU General Public License v3.0 | 5 votes |
/** Creates new form AddTerrainRangeDialog */ public AddTerrainRangeDialog(Window parent, int maxHeight, ColourScheme colourScheme) { super(parent); this.colourScheme = colourScheme; initComponents(); spinnerLevel.setModel(new SpinnerNumberModel(maxHeight / 2, 1, maxHeight - 1, 1)); getRootPane().setDefaultButton(buttonOK); scaleToUI(); pack(); setLocationRelativeTo(parent); }
Example #21
Source File: bug6463712.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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)); }
Example #22
Source File: JSpinnerOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example #23
Source File: JValueInteger.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
JValueInteger(Preferences _node, String _key) { super(_node, _key, ExtPreferences.TYPE_INT); int val = node.getInt(key, 0); /* text = new JTextField("" + val, 20) {{ addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { node.putInt(key, Integer.parseInt(text.getText())); setErr(null); } catch (Exception e) { setErr(e.getClass().getName() + " " + e.getMessage()); } } }); }}; */ model = new SpinnerNumberModel(new Integer(val), new Integer(Integer.MIN_VALUE), new Integer(Integer.MAX_VALUE), new Integer(1)); spinner = new JSpinner(model); spinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { try { node.putInt(key, model.getNumber().intValue()); setErr(null); } catch (Exception e) { setErr(e.getClass().getName() + " " + e.getMessage()); } } }); add(spinner, BorderLayout.CENTER); }
Example #24
Source File: SimpleThemeEditor.java From WorldPainter with GNU General Public License v3.0 | 5 votes |
public void setTheme(SimpleTheme theme) { this.theme = theme; if (theme != null) { terrainTableModel = new TerrainRangesTableModel(theme.getTerrainRanges()); terrainTableModel.setChangeListener(this); tableTerrain.setModel(terrainTableModel); tableTerrain.setDefaultRenderer(Integer.class, new DefaultTableCellRenderer()); tableTerrain.setDefaultRenderer(Terrain.class, new TerrainTableCellRenderer(colourScheme)); tableTerrain.setDefaultRenderer(JButton.class, new JButtonTableCellRenderer()); tableTerrain.setDefaultEditor(Integer.class, new JSpinnerTableCellEditor(new SpinnerNumberModel(1, 1, theme.getMaxHeight() - 1, 1))); JComboBox terrainEditor = new JComboBox(Terrain.getConfiguredValues()); terrainEditor.setRenderer(new TerrainListCellRenderer(colourScheme)); tableTerrain.setDefaultEditor(Terrain.class, new DefaultCellEditor(terrainEditor)); tableTerrain.setDefaultEditor(JButton.class, new JButtonTableCellEditor(this)); checkBoxBeaches.setSelected(theme.isBeaches()); spinnerWaterLevel.setModel(new SpinnerNumberModel(theme.getWaterHeight(), 0, theme.getMaxHeight() - 1, 1)); spinnerWaterLevel.setEnabled(checkBoxBeaches.isSelected()); checkBoxRandomise.setSelected(theme.isRandomise()); layerTableModel = new LayerRangesTableModel(theme.getMaxHeight(), theme.getLayerMap()); tableLayers.setModel(layerTableModel); tableLayers.setDefaultRenderer(Layer.class, new LayerTableCellRenderer()); tableLayers.setDefaultRenderer(JButton.class, new JButtonTableCellRenderer()); tableLayers.setDefaultEditor(Integer.class, new JSpinnerTableCellEditor(new SpinnerNumberModel(1, 1, theme.getMaxHeight() - 1, 1))); tableLayers.setDefaultEditor(JButton.class, new JButtonTableCellEditor(this)); } }
Example #25
Source File: bug6463712.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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)); }
Example #26
Source File: SVGFallbackReference.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** Creates new form SVGFallbackReference */ public SVGFallbackReference() { initComponents(); int w = getSVGWidth(); int h = getSVGHeight(); width.setModel(new SpinnerNumberModel(w, 50, 1024, 10)); height.setModel(new SpinnerNumberModel(h, 50, 1024, 10)); }
Example #27
Source File: TableLayoutConstraintEditor.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** Creates new form TableLayoutConstraintEditor */ public TableLayoutConstraintEditor(com.codename1.ui.table.TableLayout l, com.codename1.ui.table.TableLayout.Constraint con) { this.l = l; initComponents(); if(con == null) { row.setModel(new SpinnerNumberModel(-1, -1, 1000, 1)); column.setModel(new SpinnerNumberModel(-1, -1, 1000, 1)); width.setModel(new SpinnerNumberModel(-2, -1, 100, 1)); height.setModel(new SpinnerNumberModel(-1, -1, 100, 1)); hspan.setModel(new SpinnerNumberModel(1, 1, 20, 1)); vspan.setModel(new SpinnerNumberModel(1, 1, 20, 1)); } else { row.setModel(new SpinnerNumberModel(con.getRow(), -1, l.getRows() - 1, 1)); column.setModel(new SpinnerNumberModel(con.getColumn(), -1, l.getColumns() - 1, 1)); width.setModel(new SpinnerNumberModel(con.getWidthPercentage(), -2, 100, 1)); height.setModel(new SpinnerNumberModel(con.getHeightPercentage(), -1, 100, 1)); hspan.setModel(new SpinnerNumberModel(con.getHorizontalSpan(), 1, 20, 1)); vspan.setModel(new SpinnerNumberModel(con.getVerticalSpan(), 1, 20, 1)); for(int iter = 0 ; iter < ALIGN.length ; iter++) { if(ALIGN[iter] == con.getHorizontalAlign()) { align.setSelectedIndex(iter); break; } } for(int iter = 0 ; iter < VALIGN.length ; iter++) { if(VALIGN[iter] == con.getVerticalAlign()) { valign.setSelectedIndex(iter); break; } } } }
Example #28
Source File: SettingsPanel.java From visualvm with GNU General Public License v2.0 | 5 votes |
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; }
Example #29
Source File: ScaleMultiImage.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** Creates new form ScaleMultiImage */ public ScaleMultiImage(EditableResources.MultiImage m, int currentDpi) { initComponents(); int highestDPI = 0; int highestDPIOffset = 0; int scaleOffsetCounter = 0; for(int iter = 0 ; iter < DPIS.length ; iter++) { if(currentDpi == DPIS[iter]) { to.removeItemAt(iter); } else { actualDPIs[scaleOffsetCounter] = DPIS[iter]; scaleOffsetCounter++; } } for(int iter = 0 ; iter < m.getDpi().length ; iter++) { if(highestDPI < m.getDpi()[iter]) { highestDPI = m.getDpi()[iter]; highestDPIOffset = iter; } } int w = m.getInternalImages()[highestDPIOffset].getWidth(); int h = m.getInternalImages()[highestDPIOffset].getHeight(); aspectRatio = ((float)w) / ((float)h); width.setModel(new SpinnerNumberModel(w, 1, 5000, 1)); height.setModel(new SpinnerNumberModel(h, 1, 5000, 1)); }
Example #30
Source File: bug8008657.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); }