Here you can find the source of getInt(JComboBox combo)
public static int getInt(JComboBox combo)
//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 ww w . j av a2s. c om } } } 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; } }