List of usage examples for java.awt Component getParent
public Container getParent()
From source file:com.asprise.imaging.core.Imaging.java
/** Return the owning window handle of the given component or 0 if failed to determine. */ private static long getOwningWindowHandle(Component component) { if (component == null) return 0; Window window = null;/* w w w . j a v a 2 s .c o m*/ Container container = component.getParent(); while (true) { if (container == null) { return 0; } if (container instanceof Window) { window = (Window) container; break; } container = container.getParent(); } return window.getPeer() != null ? ((WComponentPeer) window.getPeer()).getHWnd() : 0; }
From source file:com.projity.dialog.AbstractDialog.java
public static JDialog containedInDialog(Object object) { if (!(object instanceof Component)) return null; Component c = (Component) object; while (c != null) { if (c instanceof JDialog) return (JDialog) c; c = c.getParent(); }//from w w w. j av a2 s .co m return null; }
From source file:pcgen.gui2.tools.Utility.java
/** * Get the tabbed pane for a component/*from www . j a v a 2s.c om*/ * * @param c * @return the tabbed pane for a component */ @Contract("null -> null") public static JTabbedPane getTabbedPaneFor(Component c) { if (c == null) { return null; } if (c instanceof JTabbedPane) { return (JTabbedPane) c; } return getTabbedPaneFor(c.getParent()); }
From source file:Main.java
/** * Returns root pane for the specified component or null if it doesn't exist. * * @param component component to look under * @return root pane for the specified component or null if it doesn't exist *///from www . j a v a 2s . co m public static JRootPane getRootPane(final Component component) { if (component == null) { return null; } else if (component instanceof JFrame) { return ((JFrame) component).getRootPane(); } else if (component instanceof JDialog) { return ((JDialog) component).getRootPane(); } else if (component instanceof JWindow) { return ((JWindow) component).getRootPane(); } else if (component instanceof JApplet) { return ((JApplet) component).getRootPane(); } else if (component instanceof JRootPane) { return (JRootPane) component; } else { return getRootPane(component.getParent()); } }
From source file:org.eclipse.wb.internal.swing.utils.SwingImageUtils.java
private static void fetchMenuVisualData_JMenu_JPopupMenu(MenuVisualData menuData, Container menuObject) throws Exception { JPopupMenu popupMenu = menuObject instanceof JPopupMenu ? (JPopupMenu) menuObject : ((JMenu) menuObject).getPopupMenu(); // image/*from www. j av a 2 s . c om*/ { prepareForPrinting(popupMenu); // OSX Java since jdk 1.6.0_20 requires menu invoker to be visible. // traverse parents until null or already visible and make sure that all are visible. // CHECK: it could flash on Windows. Point parentLocation = null; Component parent = popupMenu.getInvoker(); while (parent != null && !parent.isShowing()) { Container parent2 = parent.getParent(); if (parent2 != null) { parent = parent2; } else { break; } } if (parent != null) { parentLocation = parent.getLocation(); prepareForPrinting(parent); } // fetch image try { Container popupMenuParent = popupMenu.getParent(); if (popupMenuParent != null) { popupMenuParent.doLayout(); } popupMenu.doLayout(); menuData.m_menuImage = createComponentShot(popupMenu); } finally { setVisible(popupMenu, false); if (parent != null) { parent.setLocation(parentLocation); if (parent instanceof JPopupMenu) { setVisible(parent, false); } } } } // bounds { org.eclipse.swt.graphics.Rectangle imageBounds = menuData.m_menuImage.getBounds(); menuData.m_menuBounds = new Rectangle(0, 0, imageBounds.width, imageBounds.height); } // items fetchMenuVisualData_items(menuData, popupMenu); }
From source file:com.openbravo.pos.customers.JCustomerFinder.java
private static Window getWindow(Component parent) { if (parent == null) { return new JFrame(); } else if (parent instanceof Frame || parent instanceof Dialog) { return (Window) parent; } else {/*from w w w .jav a 2s . c o m*/ return getWindow(parent.getParent()); } }
From source file:Main.java
public void removeMinMaxClose(Component comp) { if (comp instanceof AbstractButton) { comp.getParent().remove(comp); }// w ww . j a v a 2 s . c o m if (comp instanceof Container) { Component[] comps = ((Container) comp).getComponents(); for (int x = 0, y = comps.length; x < y; x++) { removeMinMaxClose(comps[x]); } } }
From source file:org.eclipse.wb.internal.swing.model.component.exposed.SwingHierarchyProvider.java
@Override public Object getParentObject(Object object) throws Exception { if (object instanceof JMenuItem) { return getJMenu((JMenuItem) object); }/* w ww .j a v a 2s .com*/ if (object instanceof Component) { Component component = (Component) object; return component.getParent(); } return null; }
From source file:com.quinsoft.zeidon.objectbrowser.WindowBoundsRestorer.java
public void save(Component component) { Component top = component; while (top.getParent() != null) top = top.getParent();/* w w w . java 2 s.c om*/ properties = new Properties(); getBounds("", top); OutputStream os = null; try { os = new FileOutputStream(filename); properties.storeToXML(os, "Browser"); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(os); } }
From source file:edu.ku.brc.af.ui.forms.ResultSetController.java
/** * /* www . j a v a 2 s. co m*/ */ private static void registerFocusListener() { final KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Component permanentFocusOwner = null; String propName = e.getPropertyName(); if (propName.equals("permanentFocusOwner")) { permanentFocusOwner = focusManager.getFocusOwner(); } Component comp = permanentFocusOwner; while (comp != null && !(comp instanceof MultiView)) { comp = comp.getParent(); } ResultSetController rsc = null; boolean fnd = false; if (comp instanceof MultiView) { FormViewObj fvo = ((MultiView) comp).getCurrentViewAsFormViewObj(); if (fvo != null && fvo.getRsController() != null) { rsc = fvo.getRsController(); if (currentFocusedRS == null || currentFocusedRS != rsc) { currentFocusedRS = rsc; fnd = true; } } } if (!fnd) { currentFocusedRS = backStopRS; } installRS(currentFocusedRS); } }); }