Java 8 JSpinner - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JSpinner class.

This code example shows how to use the following methods:getHeight, setMinimumSize, setToolTipText, getModel
 
  /** the history button. */ 
  protected JButton m_ButtonHistory = new JButton("History...");
 
  /** the spinner for the maximum number of rows. */ 
  protected JSpinner m_SpinnerMaxRows = new JSpinner();
 
  /** the connection listeners. */ 
  protected HashSet m_QueryExecuteListeners;
 
  /** the history listeners. */ 
  protected HashSet m_HistoryChangedListeners;
 
  /** for working on the database. */ 
  protected DbUtils m_DbUtils;
 
  /** whether we have a connection to a database or not. */ 
  protected boolean m_Connected;
 
  /** the query history. */ 

7
CodeRank
This code example shows how to use the following methods:
class Slider extends JPanel {
	private JSpinner spinner;
 
	public Slider (float initialValue, final float min, final float max, float stepSize, final float sliderMin,
		final float sliderMax) {
		spinner = new JSpinner(new SpinnerNumberModel(initialValue, min, max, stepSize));
		setLayout(new BorderLayout());
		add(spinner);
	} 
 
	public void setValue (float value) {
		spinner.setValue((double)value);
	} 
 
	public float getValue () { 
		return ((Double)spinner.getValue()).floatValue();
	} 
 
	public void addChangeListener (ChangeListener listener) {
		spinner.addChangeListener(listener);
6
CodeRank
This code example shows how to use the following methods:getValue
	public void setValue (float value) {
		spinner.setValue((double)value);
	} 
 
	public float getValue () { 
		return ((Double)spinner.getValue()).floatValue();
	} 
 
	public void addChangeListener (ChangeListener listener) {
		spinner.addChangeListener(listener);
	} 
 
	public Dimension getPreferredSize () {
		Dimension size = super.getPreferredSize();
		size.width = 75;
		size.height = 26;
		return size;
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getEditor, setModel
    private CopyNodes manipulator;
 
    /** Creates new form CopyNodesUI */ 
    public CopyNodesUI() { 
        initComponents(); 
        copiesSpinner.setModel(new SpinnerNumberModel(1, 1, 100, 1));//Min: 1, Max:500
        JFormattedTextField spinnerText = ((JSpinner.DefaultEditor) copiesSpinner.getEditor()).getTextField();
        spinnerText.setEditable(false);//Not editable with keyboard
    } 
 
    public void setup(Manipulator m, DialogControls dialogControls) {
        this.manipulator = (CopyNodes) m;
        copiesSpinner.setValue(manipulator.getCopies());
    } 
 
    public void unSetup() { 
        manipulator.setCopies((Integer) copiesSpinner.getValue());
    } 
 
    public String getDisplayName() {

6
CodeRank
This code example shows how to use the following methods:getValue
 
		valueSpinner.setValue(value.getValue());
 
		valueSpinner.addChangeListener(new ChangeListener() {
			public void stateChanged (ChangeEvent event) {
				value.setValue((Float)valueSpinner.getValue());
			} 
		}); 
	} 
 
	private void initializeComponents () { 
		JPanel contentPanel = getContentPanel();
		{ 
			JLabel label = new JLabel("Value:");
			contentPanel.add(label, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE,
				new Insets(0, 0, 0, 6), 0, 0));
		} 
		{ 
			valueSpinner = new JSpinner(new SpinnerNumberModel(new Float(0), new Float(-99999), new Float(99999), new Float(0.1f)));
			contentPanel.add(valueSpinner, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST,
6
CodeRank
This code example shows how to use the following methods:setValue
		setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), title));
		setSize(250, 150); 
		 
		SpinnerModel model = new SpinnerNumberModel(Math.round(setPoint*100), 0, 100, 1); 
		 
		setPointTemperatureSpinner = new JSpinner(model);
		 
		//setPointTemperatureSpinner.setEditor(new JSpinner.NumberEditor(setPointTemperatureSpinner, " %")); 
		setPointTemperatureSpinner.setValue((Integer)Math.round(setPoint*100));
		 
		add(setPointTemperatureSpinner, BorderLayout.CENTER);
	} 
 
	public float temperatureStep(float roomTemperature) {
		 
		float setPoint = new Float((Integer)setPointTemperatureSpinner.getValue()/100.0);
		/* Add innaccuracy */ 
		roomTemperature = roomTemperature - (float)0.4 + ((float)Math.random() * (float)0.8);
		setPoint = setPoint - (float)0.01 + ((float)Math.random() * (float)0.02);
		 
6
CodeRank
This code example shows how to use the following methods:addChangeListener, setModel
6
CodeRank
This code example shows how to use the following methods:getPreferredSize, setEnabled, setPreferredSize, addChangeListener, getValue
			spinner = new JSpinner(model);
			spinner.setValue(lastSelected);
		} 
		else 
		{ 
			spinner = new JSpinner();
			spinner.setEnabled(false);
		} 
		 
		// TODO: hard-coded constant 3. 
		spinner.setPreferredSize(new Dimension(
				((int)spinner.getPreferredSize().getWidth())*3,
				(int)spinner.getPreferredSize().getHeight())
		); 
		 
		spinner.addChangeListener(this);
		 
		buttonsPanel.add(spinner);
		 
		 

6
CodeRank
This code example shows how to use the following methods:addChangeListener, setModel
 */ 
public class bug6463712 implements ChangeListener {
 
    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));
    } 
 
    public void stateChanged(ChangeEvent e) {
        throw new RuntimeException("Should not receive this event.");
    } 
 
    public static void main(String[] args) {
6
CodeRank
This code example shows how to use the following methods:addChangeListener, setModel
 */ 
public class bug6463712 implements ChangeListener {
 
    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));
    } 
 
    public void stateChanged(ChangeEvent e) {
        throw new RuntimeException("Should not receive this event.");
    } 
 
    public static void main(String[] args) {
6
CodeRank
See Code Examples for Java 8 JSpinner Methods: