Java JPanel Child resetControlsInAPanel(JPanel panel)

Here you can find the source of resetControlsInAPanel(JPanel panel)

Description

reset Controls In A Panel

License

Open Source License

Declaration

public static void resetControlsInAPanel(JPanel panel) 

Method Source Code

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

import javax.swing.*;
import java.awt.*;

public class Main {
    public static void resetControlsInAPanel(JPanel panel) {
        for (Component cmp : panel.getComponents()) {
            if (cmp instanceof JTextField) {
                ((JTextField) cmp).setText("");
            }/*ww  w .  j a v a 2 s  . c o  m*/
            if (cmp instanceof JTextArea) {
                ((JTextArea) cmp).setText("");
            }
            if (cmp instanceof JComboBox) {
                ((JComboBox) cmp).setSelectedItem(null);
            }
            if (cmp instanceof JList) {
                ((JList) cmp).setSelectedValue(null, false);
            }
            if (cmp instanceof JTable) {
                ((JTable) cmp).getSelectionModel().clearSelection();
            }
            if (cmp instanceof JPanel) {
                resetControlsInAPanel((JPanel) cmp);
            }
        }
    }
}

Related

  1. getOutermostContainer(JPanel container)
  2. packPanel(JPanel p, int width)
  3. padPanel(Object innerPanel, JPanel outerPanel, int pad)
  4. removeComponentFromPanel(Component removeComponent, JPanel fromPanel)
  5. removePanel(JPanel parent, JPanel panel)
  6. resizeJPanel(JPanel p)
  7. unmaskContainer(JPanel pnl)
  8. wrapInMinimizer(JPanel panel)
  9. wrapMacFancy(JPanel content)