java.awt.Container#getParent ( )源码实例Demo

下面列出了java.awt.Container#getParent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: views-widgets-samples   文件: CycleEdit.java
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);
}
 
源代码2 项目: pcgen   文件: JDynamicTable.java
@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);
		}
	}
}
 
源代码3 项目: openjdk-8   文件: XComponentPeer.java
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;
}
 
源代码4 项目: meka   文件: GUIHelper.java
/**
 * 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;
}
 
源代码5 项目: dragonwell8_jdk   文件: XComponentPeer.java
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;
}
 
源代码6 项目: Briss-2.0   文件: WrapLayout.java
/**
 * 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();
    }
}
 
源代码7 项目: osp   文件: VideoPlayer.java
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);

}
 
源代码8 项目: zap-extensions   文件: HttpFuzzerErrorsTable.java
/**
 * {@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;
}
 
private static void revalidateParents(Container container) {
    while (container != null) {
        container.invalidate();
        container.validate();
        container.repaint();
        container = container.getParent();
    }
}
 
private static void revalidateParents(Container container) {
    while (container != null) {
        container.invalidate();
        container.validate();
        container.repaint();
        container = container.getParent();
    }
}
 
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;
}
 
源代码12 项目: flutter-intellij   文件: FlutterSettingsStep.java
@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);
}
 
源代码13 项目: wandora   文件: AbstractTypePanel.java
protected QueryEditorComponent getEditor(){
    Container parent=getParent();
    while(parent!=null && !(parent instanceof QueryEditorComponent)){
        parent=parent.getParent();
    }
    if(parent!=null) return (QueryEditorComponent)parent;
    else return null;
}
 
源代码14 项目: pumpernickel   文件: BoxTabbedPaneUI.java
private JTabbedPane getTabbedPaneParent(Container c) {
	while (c != null) {
		if (c instanceof JTabbedPane)
			return (JTabbedPane) c;
		c = c.getParent();
	}
	return null;
}
 
源代码15 项目: hottub   文件: SortingFocusTraversalPolicy.java
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;
}
 
源代码16 项目: gcs   文件: CharacterSheetLayout.java
@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);
}
 
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;
}
 
源代码18 项目: pcgen   文件: JTreeTable.java
/**
 * 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;
	}
}
 
源代码19 项目: netbeans   文件: NavigatorContent.java
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();
    }
}
 
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;
}