Java JComponent Container getStringValue(JComponent component)

Here you can find the source of getStringValue(JComponent component)

Description

get String Value

License

BSD License

Declaration

public static String getStringValue(JComponent component) 

Method Source Code

//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;
    }
}

Related

  1. getRootPane(Component cmp)
  2. getRootPane(final Component component)
  3. getRootPaneContainer(Component c)
  4. getRootPaneContainer(Component c)
  5. getRootWindow(Component component)
  6. getTopAncestor(JComponent start)
  7. getTopLevelContainer(JComponent component)
  8. getWindow(final JComponent comp)
  9. getWindow(JComponent c)