List of usage examples for java.awt Component getParent
public Container getParent()
From source file:com.quinsoft.zeidon.objectbrowser.WindowBoundsRestorer.java
/** * Loads the properties from the .xml file and sets all named windows with a matching * name.//from ww w . j av a 2 s . c o m * * @param component Any component in the Swing app. The top-most container will be * determined from this component. */ public void restore(Component component) { properties = new Properties(); InputStream is = null; File file = new File(filename); if (!file.exists()) return; try { is = new FileInputStream(filename); properties.loadFromXML(is); } catch (IOException e) { e.printStackTrace(); return; } finally { IOUtils.closeQuietly(is); } Component top = component; while (top.getParent() != null) top = top.getParent(); setBounds("", top); }
From source file:org.jdal.swing.form.FormFocusTransversalPolicy.java
Container getTopmostProvider(Container focusCycleRoot, Component aComponent) { Container aCont = aComponent.getParent(); Container ftp = null;/*from w ww. j ava2 s . com*/ while (aCont != focusCycleRoot && aCont != null) { if (aCont.isFocusTraversalPolicyProvider()) { ftp = aCont; } aCont = aCont.getParent(); } if (aCont == null) { return null; } return ftp; }
From source file:org.kepler.gui.popups.NoLiidLibraryPopup.java
/** * @param path/*from ww w . ja va 2 s . c o m*/ * @param comp */ public NoLiidLibraryPopup(TreePath path, Component comp) { while (comp != null && !(comp instanceof PtolemyFrame)) { comp = comp.getParent(); } if (comp == null) { System.out.println("Cannot find the PtolemyFrame."); return; } setParentFrame((PtolemyFrame) comp); setSelectionPath(path); }
From source file:org.springframework.richclient.dialog.ApplicationDialog.java
/** * <p>/*from w w w . j a va2s . c om*/ * --jh-- This method is copied from JOptionPane. I'm still trying to figure * out why they chose to have a static method with package visibility for * this one instead of just making it public. * </p> * * Returns the specified component's toplevel <code>Frame</code> or * <code>Dialog</code>. * * @param parentComponent the <code>Component</code> to check for a * <code>Frame</code> or <code>Dialog</code> * @return the <code>Frame</code> or <code>Dialog</code> that contains * the component, or the default frame if the component is <code>null</code>, * or does not have a valid <code>Frame</code> or <code>Dialog</code> * parent * @exception HeadlessException if * <code>GraphicsEnvironment.isHeadless</code> returns <code>true</code> * @see java.awt.GraphicsEnvironment#isHeadless */ public static Window getWindowForComponent(Component parentComponent) throws HeadlessException { if (parentComponent == null) return JOptionPane.getRootFrame(); if (parentComponent instanceof Frame || parentComponent instanceof Dialog) return (Window) parentComponent; return getWindowForComponent(parentComponent.getParent()); }
From source file:org.jdal.swing.form.FormFocusTransversalPolicy.java
/** * @param component//from w w w.ja v a2 s . c o m * @return */ @SuppressWarnings("unused") private FocusTraversalPolicy getFocusTraversalPolicyForComponent(Component component) { Container c = null; while ((c = component.getParent()) != null) { if (c.isFocusTraversalPolicyProvider()) return c.getFocusTraversalPolicy(); component = c; } return null; }
From source file:org.nuclos.client.ui.CenteringPanel.java
/** * creates a new CenteringPanel around the given component. * @param compChild//from w ww . ja v a 2 s . c o m * @precondition compChild != null * @postcondition this.getComponentCount() == 1 * @postcondition compChild.getParent() == this * @postcondition !this.isFilled() */ public CenteringPanel(Component compChild) { this(compChild, false); assert this.getComponentCount() == 1; assert compChild.getParent() == this; assert !this.isFilled(); }
From source file:org.kepler.gui.popups.LibraryPopup.java
/** * @param path//from ww w.j av a 2s . com * @param comp */ public LibraryPopup(TreePath path, Component comp) { while (comp != null && !(comp instanceof PtolemyFrame)) { comp = comp.getParent(); } if (comp == null) { System.out.println("Cannot find the PtolemyFrame."); return; } setParentFrame((PtolemyFrame) comp); setSelectionPath(path); try { Object obj = getSelectionPath().getLastPathComponent(); if (obj instanceof ComponentEntity) { int liid = LibraryManager.getLiidFor((ComponentEntity) obj); if (isDebugging) log.debug(liid); if (liid != -1) { setLiid(liid); } else { throw new Exception( "LIID not found for " + ((NamedObj) obj).getName() + " " + obj.getClass().getName()); } } else { throw new Exception("Object must be a NamedObj"); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.github.srec.rec.DefaultScreenShot.java
private JInternalFrame findInternalFramesubdir(Component component) { while (component != null && !(component instanceof JInternalFrame)) { component = component.getParent(); }/*from w w w. ja v a 2 s . c om*/ return component != null ? (JInternalFrame) component : null; }
From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java
Component MRMAncestor() { Component c = null; for (c = _cp; c != null && c.getClass() != MRMDialog.class; c = c.getParent()) ;// w ww . j a va 2 s. co m return (c == null) ? null : (MRMDialog) c; }
From source file:org.jdal.swing.form.FormFocusTransversalPolicy.java
@Override public Component getComponentAfter(Container container, Component component) { // Fix awt bug looking for ComboBoxEditor instead ComboBox // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6205817 if (component.getParent() instanceof JComboBox) component = component.getParent(); int index = components.indexOf(component); if (index == -1) { // not owner Container childContainer = getTopmostProvider(container, component); if (childContainer == null) return getFirstComponent(container); FocusTraversalPolicy ftp = childContainer.getFocusTraversalPolicy(); if (ftp != null && ftp != this) { Component next = ftp.getComponentAfter(childContainer, component); if (next != ftp.getFirstComponent(container)) return next; // child cycle do {//w w w. ja v a2s . c o m index = components.indexOf(childContainer); childContainer = childContainer.getParent(); } while (index == -1 || childContainer == null); if (index == -1) { log.warn("I can't figure what is the next component"); return getFirstComponent(container); } } } index++; if (index < components.size() && index >= 0) { Component c = getComponent(index); if (c.isEnabled() && c.isFocusable()) return c; else return getComponentAfter(container, c); } return getFirstComponent(container); }