javax.swing.JComponent.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中javax.swing.JComponent.getParent()方法的一些代码示例,展示了JComponent.getParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComponent.getParent()方法的具体详情如下:
包路径:javax.swing.JComponent
类名称:JComponent
方法名:getParent

JComponent.getParent介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-util

/** 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));
}

代码示例来源:origin: stackoverflow.com

JOptionPane pane = null;
if (!(parent instanceof JOptionPane)) {
  pane = getOptionPane((JComponent)parent.getParent());
} else {
  pane = (JOptionPane) parent;

代码示例来源:origin: ron190/jsql-injection

/**
 * Returns true if the specified widget is in a toolbar.
 */
static boolean isToolBarButton(JComponent c) {
  return c.getParent() instanceof JToolBar;
}

代码示例来源:origin: org.netbeans.api/org-openide-util-ui

/** 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));
}

代码示例来源:origin: freeplane/freeplane

public JComponent getContent() {
  final JComponent c = contentPane == null ? mainView : contentPane;
  assert (c == null || c.getParent() == this);
  return c;
}

代码示例来源:origin: in.jlibs/org-netbeans-api-visual

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;
  }
}

代码示例来源:origin: protegeproject/protege

protected static void removeComponentFromParent(JComponent component) {
  if (component.getParent() != null){
    component.getParent().remove(component);
  }
}

代码示例来源:origin: org.protege/protege-editor-owl

protected static void removeComponentFromParent(JComponent component) {
  if (component.getParent() != null){
    component.getParent().remove(component);
  }
}

代码示例来源:origin: edu.stanford.protege/protege-editor-owl

protected static void removeComponentFromParent(JComponent component) {
  if (component.getParent() != null){
    component.getParent().remove(component);
  }
}

代码示例来源:origin: kaikramer/keystore-explorer

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;
}

代码示例来源:origin: kaikramer/keystore-explorer

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;
}

代码示例来源:origin: stackoverflow.com

public void actionPerformed(ActionEvent evt) {
  JComponent source = (JComponent) evt.getSource();
  Container tabComponent = source.getParent();
  int tabIndex = jTabbedPane1.indexOfTabComponent(tabComponent);
  jTabbedPane1.removeTabAt(tabIndex);
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
 * Updates the ui of the columnControl if appropriate.
 */
protected void updateColumnControlUI() {
  if ((columnControlButton != null)
      && (columnControlButton.getParent() == null)) {
    SwingUtilities.updateComponentTreeUI(columnControlButton);
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

@Override
public Dimension getMaximumSize(JComponent c) {
  Gripper gripper = (Gripper) c;
  if (gripper.getOrientation() == SwingConstants.HORIZONTAL)
    return new Dimension(_size, c.getParent().getHeight());
  else
    return new Dimension(c.getParent().getWidth(), _size);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** 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));
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

/**
 * Updates the ui of the columnControl if appropriate.
 */
protected void updateColumnControlUI() {
  if ((columnControlButton != null)
      && (columnControlButton.getParent() == null)) {
    SwingUtilities.updateComponentTreeUI(columnControlButton);
  }
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

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());
}

代码示例来源:origin: org.appdapter/org.appdapter.lib.gui

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;
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

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;
}

代码示例来源:origin: net.sf.nimrod/nimrod-laf

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);
 }
}

相关文章

JComponent类方法