/** Create an icon. * @param comp a component, which must be unattached to a container * and should not be used for other purposes */ public ComponentIcon(JComponent comp) { if (comp.getParent() != null) { throw new IllegalArgumentException(); } this.comp = comp; Dimension size = comp.getPreferredSize(); // Careful! If you have e.g. a JLabel with empty text, width = 0 => exceptions. // Must make sure it is at least a reasonable size. comp.setSize(Math.max(size.width, 16), Math.max(size.height, 16)); }
JOptionPane pane = null; if (!(parent instanceof JOptionPane)) { pane = getOptionPane((JComponent)parent.getParent()); } else { pane = (JOptionPane) parent;
/** * Returns true if the specified widget is in a toolbar. */ static boolean isToolBarButton(JComponent c) { return c.getParent() instanceof JToolBar; }
/** Create an icon. * @param comp a component, which must be unattached to a container * and should not be used for other purposes */ public ComponentIcon(JComponent comp) { if (comp.getParent() != null) { throw new IllegalArgumentException(); } this.comp = comp; Dimension size = comp.getPreferredSize(); // Careful! If you have e.g. a JLabel with empty text, width = 0 => exceptions. // Must make sure it is at least a reasonable size. comp.setSize(Math.max(size.width, 16), Math.max(size.height, 16)); }
public JComponent getContent() { final JComponent c = contentPane == null ? mainView : contentPane; assert (c == null || c.getParent() == this); return c; }
private JScrollPane findScrollPane (JComponent component) { for (;;) { if (component == null) return null; if (component instanceof JScrollPane) return ((JScrollPane) component); Container parent = component.getParent (); if (! (parent instanceof JComponent)) return null; component = (JComponent) parent; } }
private static JFrame findContainingFrame(JComponent component) { Container container = component.getParent(); while (container != null) { if (container instanceof JFrame) { return (JFrame) container; } container = container.getParent(); } return null; }
private static JDialog findContainingDialog(JComponent component) { Container container = component.getParent(); while (container != null) { if (container instanceof JDialog) { return (JDialog) container; } container = container.getParent(); } return null; }
public void actionPerformed(ActionEvent evt) { JComponent source = (JComponent) evt.getSource(); Container tabComponent = source.getParent(); int tabIndex = jTabbedPane1.indexOfTabComponent(tabComponent); jTabbedPane1.removeTabAt(tabIndex); }
/** * Updates the ui of the columnControl if appropriate. */ protected void updateColumnControlUI() { if ((columnControlButton != null) && (columnControlButton.getParent() == null)) { SwingUtilities.updateComponentTreeUI(columnControlButton); } }
/** Create an icon. * @param comp a component, which must be unattached to a container * and should not be used for other purposes */ public ComponentIcon (JComponent comp) { if (comp.getParent () != null) throw new IllegalArgumentException (); this.comp = comp; Dimension size = comp.getPreferredSize (); // Careful! If you have e.g. a JLabel with empty text, width = 0 => exceptions. // Must make sure it is at least a reasonable size. comp.setSize (Math.max (size.width, 16), Math.max (size.height, 16)); }
/** * Updates the ui of the columnControl if appropriate. */ protected void updateColumnControlUI() { if ((columnControlButton != null) && (columnControlButton.getParent() == null)) { SwingUtilities.updateComponentTreeUI(columnControlButton); } }
public void invalidateLayout(Container _c) { // System.out.println("LEFT ="+left_ .isVisible()); // System.out.println("RIGHT="+right_.isVisible()); divider1_.setVisible ( (left_.getParent() ==this)&&left_ .isVisible() &&(middle_.getParent()==this)&&middle_.isVisible()); divider2_.setVisible ((right_.getParent()==this)&&right_.isVisible()); }
public static Object drefJ(Object value) { Object o = dref(value, false); if (o == value) { if (o instanceof JComponent) { o = ((JComponent) o).getParent(); if (o != null && o != value) { o = drefJ(o); } } } return o; }
public static String getHelpUrl(final JComponent _c) { if (_c == null) { return null; } String r = (String) _c.getClientProperty(CtuluLib.getHelpProperty()); if (r == null) { final Container parent = _c.getParent(); if (parent instanceof JComponent) { r = (String) ((JComponent) parent).getClientProperty(CtuluLib.getHelpProperty()); } } return r; }
public void update( Graphics g, JComponent c) { oldOpaque = c.isOpaque(); if ( c.getParent() instanceof JToolBar ) { super.update( g,c); } else { c.setOpaque( false); super.update( g,c); c.setOpaque( oldOpaque); } }