Java Code Examples for java.awt.Container#getParent()
The following examples show how to use
java.awt.Container#getParent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JDynamicTable.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void unconfigureEnclosingScrollPane() { super.unconfigureEnclosingScrollPane(); Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, null); } } }
Example 2
Source File: CycleEdit.java From views-widgets-samples with Apache License 2.0 | 6 votes |
void updateTabName(String name) { if (DEBUG) { System.out.println(">>>>>" + name + " " + MainPanel.getTabbIndex(this)); StackTraceElement[] s = new Throwable().getStackTrace(); System.out.println(" .(" + s[1].getFileName() + ":" + s[1].getLineNumber() + ") "); System.out.println(" .(" + s[2].getFileName() + ":" + s[2].getLineNumber() + ") "); } Container tabb = getParent(); while (!(tabb instanceof JTabbedPane)) { tabb = tabb.getParent(); } JTabbedPane tabbedPane = (JTabbedPane) tabb; int index = MainPanel.getTabbIndex(this); tabbedPane.setTitleAt(index, name); // tabUI = new TabUI(name); // tabbedPane.setTabComponentAt(index, tabUI); }
Example 3
Source File: XComponentPeer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public boolean isObscured() { Container container = (target instanceof Container) ? (Container)target : target.getParent(); if (container == null) { return true; } Container parent; while ((parent = container.getParent()) != null) { container = parent; } if (container instanceof Window) { XWindowPeer wpeer = (XWindowPeer)(container.getPeer()); if (wpeer != null) { return (wpeer.winAttr.visibilityState != wpeer.winAttr.AWT_UNOBSCURED); } } return true; }
Example 4
Source File: GUIHelper.java From meka with GNU General Public License v3.0 | 6 votes |
/** * Tries to determine the parent this panel is part of. * * @param cont the container to get the parent for * @param parentClass the class of the parent to obtain * @return the parent if one exists or null if not */ public static Object getParent(Container cont, Class parentClass) { Container result; Container parent; result = null; parent = cont; while (parent != null) { if (parentClass.isInstance(parent)) { result = parent; break; } else { parent = parent.getParent(); } } return result; }
Example 5
Source File: XComponentPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public boolean isObscured() { Container container = (target instanceof Container) ? (Container)target : target.getParent(); if (container == null) { return true; } Container parent; while ((parent = container.getParent()) != null) { container = parent; } if (container instanceof Window) { XWindowPeer wpeer = (XWindowPeer)(container.getPeer()); if (wpeer != null) { return (wpeer.winAttr.visibilityState != wpeer.winAttr.AWT_UNOBSCURED); } } return true; }
Example 6
Source File: HttpFuzzerErrorsTable.java From zap-extensions with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * <p>Overridden to take into account for possible parent {@code JLayer}s. * * @see javax.swing.JLayer */ // Note: Same implementation as in JXTable#getEnclosingScrollPane() but changed to get the // parent and viewport view using // the methods SwingUtilities#getUnwrappedParent(Component) and // SwingUtilities#getUnwrappedView(JViewport) respectively. @Override protected JScrollPane getEnclosingScrollPane() { Container p = SwingUtilities.getUnwrappedParent(this); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || SwingUtilities.getUnwrappedView(viewport) != this) { return null; } return scrollPane; } } return null; }
Example 7
Source File: WrapLayout.java From Briss-2.0 with GNU General Public License v3.0 | 6 votes |
/** * Layout the components in the Container using the layout logic of the parent * FlowLayout class. * * @param target the Container using this WrapLayout */ @Override public final void layoutContainer(final Container target) { Dimension size = preferredLayoutSize(target); // When a frame is minimized or maximized the preferred size of the // Container is assumed not to change. Therefore we need to force a // validate() to make sure that space, if available, is allocated to // the panel using a WrapLayout. if (size.equals(preferredLayoutSize)) { super.layoutContainer(target); } else { preferredLayoutSize = size; Container top = target; while (!(top instanceof Window) && top.getParent() != null) { top = top.getParent(); } top.validate(); } }
Example 8
Source File: VideoPlayer.java From osp with GNU General Public License v3.0 | 6 votes |
public void showGoToDialog() { if (goToDialog==null) { goToDialog = new GoToDialog(this); // center dialog on videoPanel view Container c = VideoPlayer.this.getParent(); while (c!=null) { if (c instanceof JSplitPane) { Dimension dim = c.getSize(); Point p = c.getLocationOnScreen(); int x = (dim.width - goToDialog.getBounds().width) / 2; int y = (dim.height - goToDialog.getBounds().height) / 2; goToDialog.setLocation(p.x+x, p.y+y); break; } c = c.getParent(); } } else { goToDialog.setPlayer(this); } goToDialog.setVisible(true); }
Example 9
Source File: SortingFocusTraversalPolicy.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
Container getTopmostProvider(Container focusCycleRoot, Component aComponent) { Container aCont = aComponent.getParent(); Container ftp = null; while (aCont != focusCycleRoot && aCont != null) { if (aCont.isFocusTraversalPolicyProvider()) { ftp = aCont; } aCont = aCont.getParent(); } if (aCont == null) { return null; } return ftp; }
Example 10
Source File: NavigatorContent.java From netbeans with Apache License 2.0 | 5 votes |
private void selectElementInPane(final JEditorPane pane, final TreeNodeAdapter tna, final boolean focus) { RP.post(new Runnable() { public void run() { pane.setCaretPosition(tna.getDocumentElement().getStartOffset()); } }); if(focus) { // try to activate outer TopComponent Container temp = pane; while (!(temp instanceof TopComponent)) { temp = temp.getParent(); } ((TopComponent) temp).requestActive(); } }
Example 11
Source File: JTreeTable.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
/** * Forwards the {@code scrollRectToVisible()} message to the * {@code JComponent}'s parent. Components that can service * the request, such as {@code JViewport}, * override this method and perform the scrolling. * * @param aRect the visible {@code Rectangle} * @see javax.swing.JViewport */ @Override public void scrollRectToVisible(Rectangle aRect) { Container parent; int dx = getX(); int dy = getY(); for (parent = getParent(); (parent != null) && !(parent instanceof JComponent) && !(parent instanceof CellRendererPane); parent = parent.getParent()) { final Rectangle bounds = parent.getBounds(); dx += bounds.x; dy += bounds.y; } if ((parent != null) && !(parent instanceof CellRendererPane)) { aRect.x += dx; aRect.y += dy; ((JComponent) parent).scrollRectToVisible(aRect); aRect.x -= dx; aRect.y -= dy; } }
Example 12
Source File: SortingFocusTraversalPolicy.java From JDKSourceCode1.8 with MIT License | 5 votes |
Container getTopmostProvider(Container focusCycleRoot, Component aComponent) { Container aCont = aComponent.getParent(); Container ftp = null; while (aCont != focusCycleRoot && aCont != null) { if (aCont.isFocusTraversalPolicyProvider()) { ftp = aCont; } aCont = aCont.getParent(); } if (aCont == null) { return null; } return ftp; }
Example 13
Source File: CharacterSheetLayout.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public Dimension preferredLayoutSize(Container target) { Insets insets = target.getInsets(); Component[] children = target.getComponents(); int across = 1; int width = 0; int height = 0; int margin = mSheet.getScale().scale(MARGIN); if (children.length > 0) { Dimension size = children[0].getPreferredSize(); Container parent = target.getParent(); if (parent != null) { Insets parentInsets = parent.getInsets(); int avail = parent.getWidth() - (parentInsets.left + parentInsets.right); int pageWidth = size.width; avail -= insets.left + insets.right + pageWidth; pageWidth += margin; while (true) { avail -= pageWidth; if (avail >= 0) { across++; } else { break; } } } width = (size.width + margin) * across - margin; int pagesDown = children.length / across; if (children.length % across != 0) { pagesDown++; } height = (size.height + margin) * pagesDown - margin; } return new Dimension(insets.left + insets.right + width, insets.top + insets.bottom + height); }
Example 14
Source File: SortingFocusTraversalPolicy.java From hottub with GNU General Public License v2.0 | 5 votes |
Container getTopmostProvider(Container focusCycleRoot, Component aComponent) { Container aCont = aComponent.getParent(); Container ftp = null; while (aCont != focusCycleRoot && aCont != null) { if (aCont.isFocusTraversalPolicyProvider()) { ftp = aCont; } aCont = aCont.getParent(); } if (aCont == null) { return null; } return ftp; }
Example 15
Source File: BoxTabbedPaneUI.java From pumpernickel with MIT License | 5 votes |
private JTabbedPane getTabbedPaneParent(Container c) { while (c != null) { if (c instanceof JTabbedPane) return (JTabbedPane) c; c = c.getParent(); } return null; }
Example 16
Source File: AbstractTypePanel.java From wandora with GNU General Public License v3.0 | 5 votes |
protected QueryEditorComponent getEditor(){ Container parent=getParent(); while(parent!=null && !(parent instanceof QueryEditorComponent)){ parent=parent.getParent(); } if(parent!=null) return (QueryEditorComponent)parent; else return null; }
Example 17
Source File: FlutterSettingsStep.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onWizardStarting(@NotNull ModelWizard.Facade wizard) { FlutterProjectModel model = getModel(); myKotlinCheckBox.setText(FlutterBundle.message("module.wizard.language.name_kotlin")); mySwiftCheckBox.setText(FlutterBundle.message("module.wizard.language.name_swift")); myBindings.bindTwoWay(new SelectedProperty(myUseAndroidxCheckBox), getModel().useAndroidX()); TextProperty packageNameText = new TextProperty(myPackageName); Expression<String> computedPackageName = new DomainToPackageExpression(model.companyDomain(), model.projectName()) { @Override public String get() { return super.get().replaceAll("_", ""); } }; BoolProperty isPackageSynced = new BoolValueProperty(true); myBindings.bind(packageNameText, computedPackageName, isPackageSynced); myBindings.bind(model.packageName(), packageNameText); myListeners.listen(packageNameText, value -> isPackageSynced.set(value.equals(computedPackageName.get()))); // The wizard changed substantially in 3.5. Something causes this page to not get properly validated // after it is added to the Swing tree. Here we check that we have to validate the tree, then do so. // It only needs to be done once, so we remove the listener to prevent possible flicker. focusListener = new FocusAdapter() { @Override public void focusGained(FocusEvent e) { super.focusGained(e); Container parent = myRoot; while (parent != null && !(parent instanceof JBLayeredPane)) { parent = parent.getParent(); } if (parent != null) { parent.validate(); } myPackageName.removeFocusListener(focusListener); } }; myPackageName.addFocusListener(focusListener); }
Example 18
Source File: SortingFocusTraversalPolicy.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
Container getTopmostProvider(Container focusCycleRoot, Component aComponent) { Container aCont = aComponent.getParent(); Container ftp = null; while (aCont != focusCycleRoot && aCont != null) { if (aCont.isFocusTraversalPolicyProvider()) { ftp = aCont; } aCont = aCont.getParent(); } if (aCont == null) { return null; } return ftp; }
Example 19
Source File: HierarchicalControllerTopComponent.java From constellation with Apache License 2.0 | 5 votes |
private static void revalidateParents(Container container) { while (container != null) { container.invalidate(); container.validate(); container.repaint(); container = container.getParent(); } }
Example 20
Source File: KTrussControllerTopComponent.java From constellation with Apache License 2.0 | 5 votes |
private static void revalidateParents(Container container) { while (container != null) { container.invalidate(); container.validate(); container.repaint(); container = container.getParent(); } }