Here you can find the source of getStringValue(JComponent component)
public static String getStringValue(JComponent component)
//package com.java2s; // LICENSE: This file is distributed under the BSD license. import javax.swing.*; import javax.swing.text.JTextComponent; public class Main { public static String getStringValue(JComponent component) { if (component instanceof JTextComponent) { return ((JTextComponent) component).getText(); }//from ww w . j a v a2 s. c o m if (component instanceof JComboBox) { return ((JComboBox) component).getSelectedItem().toString(); } if (component instanceof JList) { return ((JList) component).getSelectedValue().toString(); } return null; } }