Java JSpinner getInt(JSpinner spinner)

Here you can find the source of getInt(JSpinner spinner)

Description

get Int

License

Open Source License

Declaration

public static int getInt(JSpinner spinner) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JComboBox;

import javax.swing.JSpinner;

public class Main {
    public static int getInt(JComboBox combo) {
        int rv = 0;
        Object o = combo.getSelectedItem();
        if (o != null) {
            if (o instanceof Number) {
                rv = ((Number) o).intValue();
            } else {
                String s = o.toString();
                if (s != null) {
                    try {
                        rv = Integer.parseInt(s.trim());
                    } catch (NumberFormatException ex) {
                    }/*from   w  w w.j a  v a 2  s .com*/
                }
            }
        }
        return rv;
    }

    public static int getInt(JSpinner spinner) {
        int rv = 0;
        Object o = spinner.getValue();
        if (o != null) {
            if (o instanceof Number) {
                rv = ((Number) o).intValue();
            }
        }
        return rv;
    }
}

Related

  1. detachChangeListeners(JSpinner spinner)
  2. fixIntegerList(final JSpinner spinner)
  3. formatSpinner(JSpinner spinner, String format)
  4. generateSpinnerFor(Object... objs)
  5. getFloat(JSpinner spinner)
  6. getInt(SpinnerNumberModel model)
  7. getOnlySpinner(Container owner)
  8. getSpinnerFloatValue(JSpinner sp)
  9. getSpinnerFormatter(JSpinner spinner)