List of usage examples for javax.swing JComponent getComponents
public Component[] getComponents()
From source file:Main.java
/** * Recursively remove all PropertyChangeListeners from a component * @param container//from www .j a v a 2 s . co m */ public static void removeAllPropertyChangeListeners(JComponent component) { if (component.getComponentCount() > 0) { for (Component child : component.getComponents()) { if (child instanceof JComponent) { removeAllPropertyChangeListeners((JComponent) child); } } } PropertyChangeListener[] tmpList = component.getPropertyChangeListeners(); for (PropertyChangeListener listener : tmpList) { component.removePropertyChangeListener(listener); } }
From source file:Main.java
/** * Remove all children from a JCompontent and remove all * PropertyChangeListeners for all children recursively. * * @param container//from ww w . j a va2s . co m */ public static void safeRemoveAll(JComponent container) { //remove all children PropertyChangeListeners if (container.getComponentCount() > 0) { for (Component child : container.getComponents()) { removeAllPropertyChangeListeners((JComponent) child); } } //remove all children container.removeAll(); }
From source file:org.drugis.addis.gui.builder.SMAAView.java
private static ChartPanel findChartPanel(JComponent viewPanel) { for (Component c : viewPanel.getComponents()) { if (c instanceof ChartPanel) { return (ChartPanel) c; }// ww w. ja va2 s. c om } return null; }
From source file:Main.java
public static void printTree(JComponent c, int tabs) { if (c.getName() != null && !c.getName().contains("null") || tabs == 0) { for (int i = 0; i < tabs; i++) System.out.print(" "); System.out.println(c.getName() + " [" + c.getClass().getSimpleName() + "]"); } else//from w w w . j a v a2 s . c o m tabs--; if (c.getComponents() == null) return; for (Component ci : c.getComponents()) { if (ci instanceof JComponent) printTree((JComponent) ci, tabs + 1); } }
From source file:com.clank.launcher.swing.SwingHelper.java
/** * Remove all the opaqueness of the given components and child components. * * @param components list of components//w w w . j av a 2s . c o m */ public static void removeOpaqueness(@NonNull Component... components) { for (Component component : components) { if (component instanceof JComponent) { JComponent jComponent = (JComponent) component; jComponent.setOpaque(false); removeOpaqueness(jComponent.getComponents()); } } }
From source file:Main.java
public static void setFont(JComponent component, Font font, ComponentOrientation componentOrientation) { component.setFont(font);/* www . j av a2 s .com*/ if (component instanceof JTextField) { component.setComponentOrientation(componentOrientation); } if (component instanceof JTextArea) { component.setComponentOrientation(componentOrientation); } if (component instanceof JTextPane) { component.setComponentOrientation(componentOrientation); } if (component instanceof JScrollPane) { for (Component cmp : component.getComponents()) { setFont((JComponent) cmp, font, componentOrientation); } } if (component instanceof JTree) { component.setComponentOrientation(componentOrientation); } if (component instanceof JComboBox) { component.setComponentOrientation(componentOrientation); JComboBox comboBox = (JComboBox) component; ((BasicComboBoxRenderer) comboBox.getRenderer()).setHorizontalAlignment(SwingConstants.RIGHT); ((BasicComboBoxRenderer) comboBox.getRenderer()).setAutoscrolls(true); comboBox.setMaximumRowCount(20); } /* if(component instanceof JLabel) { ((JLabel)component).setHorizontalTextPosition(SwingConstants.RIGHT); }*/ if (component instanceof JPanel) { JPanel panel = (JPanel) component; if (panel.getBorder() != null && panel.getBorder() instanceof TitledBorder) { ((TitledBorder) panel.getBorder()).setTitleFont(font); panel.setComponentOrientation(componentOrientation); } for (Component cmp : component.getComponents()) { setFont((JComponent) cmp, font, componentOrientation); } } if (component instanceof JTabbedPane) { JTabbedPane tabbedPane = (JTabbedPane) component; int tabCount = tabbedPane.getTabCount(); for (int i = 0; i < tabCount; i++) { setFont((JComponent) tabbedPane.getComponentAt(i), font, componentOrientation); } } }
From source file:com.limegroup.gnutella.gui.GUIUtils.java
/** * Sets the child components of a component to all be either * opaque or not opaque./*from w ww . j av a 2 s . c om*/ */ public static void setOpaque(boolean op, JComponent c) { c.setOpaque(op); Component[] cs = c.getComponents(); for (int i = 0; i < cs.length; i++) { if (cs[i] instanceof JComponent && !(cs[i] instanceof JTextField) && (ThemeSettings.isNativeOSXTheme() || !(cs[i] instanceof JButton))) { ((JComponent) cs[i]).setOpaque(op); setOpaque(op, (JComponent) cs[i]); } } }
From source file:de.ailis.xadrian.frames.MainFrame.java
/** * Installs status handler for the specified component an all its child * components./*w w w. j a v a2 s. c o m*/ * * @param component * The component to install the status handler for. */ private void installStatusHandler(final JComponent component) { final JLabel statusBar = this.statusBar; final String text = component.getToolTipText(); if (text != null && !text.isEmpty()) { component.addMouseListener(new MouseAdapter() { @Override public void mouseExited(final MouseEvent e) { statusBar.setText(" "); } @Override public void mouseEntered(final MouseEvent e) { statusBar.setText(component.getToolTipText()); } }); } for (final Component child : component.getComponents()) { if (!(child instanceof JComponent)) continue; installStatusHandler((JComponent) child); } if (component instanceof JMenu) { for (final MenuElement menuElement : ((JMenu) component).getSubElements()) { if (!(menuElement instanceof JComponent)) continue; installStatusHandler((JComponent) menuElement); } } }
From source file:op.tools.SYSTools.java
/** * luft rekursiv durch alle Kinder eines Containers und setzt deren Enabled Status auf * enabled.// w w w. ja v a2s. c o m */ public static void setXEnabled(JComponent container, boolean enabled) { // Bei einer Combobox muss die Rekursion ebenfalls enden. // Sie besteht aus weiteren Unterkomponenten // "disabled" wird sie aber bereits hier. if (container.getComponentCount() == 0 || container instanceof JComboBox) { // Rekursionsanker container.setEnabled(enabled); } else { Component[] c = container.getComponents(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof JComponent) { JComponent jc = (JComponent) c[i]; setXEnabled(jc, enabled); } } } }
From source file:op.tools.SYSTools.java
/** * luft rekursiv durch alle Kinder eines Containers und entfernt evtl. vorhandene Listener. *//*from w w w . j a v a 2 s . c o m*/ public static void unregisterListeners(JComponent container) { if (container == null) { return; } removeListeners(container); if (container.getComponentCount() > 0) { Component[] c = container.getComponents(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof JComponent) { unregisterListeners((JComponent) c[i]); } } } }