congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Container.getComponent
Code IndexAdd Tabnine to your IDE (free)

How to use
getComponent
method
in
java.awt.Container

Best Java code snippets using java.awt.Container.getComponent (Showing top 20 results out of 1,998)

Refine searchRefine arrow

  • Container.getComponentCount
  • Container.getInsets
  • Component.getPreferredSize
  • Dimension.<init>
origin: org.netbeans.api/org-openide-util

/** Find a focus-traverable component.
* @param c the component to look in
* @return the same component if traversable, else a child component if present, else <code>null</code>
* @see Component#isFocusTraversable
*/
public static Component getFocusTraversableComponent(Component c) {
  if (c.isFocusable()) {
    return c;
  }
  if (!(c instanceof Container)) {
    return null;
  }
  int i;
  int k = ((Container) c).getComponentCount();
  for (i = 0; i < k; i++) {
    Component v = ((Container) c).getComponent(i);
    if (v != null) {
      return v;
    }
  }
  return null;
}
origin: stackoverflow.com

Insets insets = target.getInsets();
if (insets == null){
 insets = new Insets(0, 0, 0, 0);
int n = target.getComponentCount();
int x = 0;
int y = insets.top + vgap; // FlowLayout starts by adding vgap, so do that here too.
 Component c = target.getComponent(i);
 if (c.isVisible()) {
   Dimension d = c.getPreferredSize();
   if ((x == 0) || ((x + d.width) <= maxwidth)) {
return new Dimension(reqdWidth+insets.left+insets.right, y);
 Component c = target.getComponent(i);
 if (c.isVisible()) {
   found_one = true;
   Dimension d = c.getPreferredSize();
   minx = Math.min(minx, d.width);
   miny = Math.min(miny, d.height);
 return new Dimension(minx, miny);
return new Dimension(0, 0);
origin: stackoverflow.com

  @Override
  public void actionPerformed(ActionEvent ae) {//focuses the first label on popwindow
    for (int i = 0; i < suggestionsPanel.getComponentCount(); i++) {
      if (suggestionsPanel.getComponent(i) instanceof SuggestionLabel) {
        ((SuggestionLabel) suggestionsPanel.getComponent(i)).setFocused(true);
        autoSuggestionPopUpWindow.toFront();
        autoSuggestionPopUpWindow.requestFocusInWindow();
        suggestionsPanel.requestFocusInWindow();
        suggestionsPanel.getComponent(i).requestFocusInWindow();
        break;
            autoSuggestionPopUpWindow.requestFocusInWindow();
            suggestionsPanel.requestFocusInWindow();
            suggestionsPanel.getComponent(i).requestFocusInWindow();
            lastFocusableIndex = i;
            break;
for (int i = 0; i < suggestionsPanel.getComponentCount(); i++) {
  if (suggestionsPanel.getComponent(i) instanceof SuggestionLabel) {
    SuggestionLabel sl = (SuggestionLabel) suggestionsPanel.getComponent(i);
    sls.add(sl);
autoSuggestionPopUpWindow.setMinimumSize(new Dimension(textField.getWidth(), 30));
autoSuggestionPopUpWindow.setSize(tW, tH);
autoSuggestionPopUpWindow.setVisible(true);
origin: stackoverflow.com

Dimension boardSize = new Dimension(600, 600);
JPanel panel = (JPanel)chessBoard.getComponent( 0 );
panel.add( piece );
piece = new JLabel( duke );
panel = (JPanel)chessBoard.getComponent( 15 );
panel.add( piece );
origin: org.netbeans.api/org-openide-awt

private int getMaximumWidth(Container target) {
  int maxWidth = 0;
  synchronized (target.getTreeLock()) {
    int nmembers = target.getComponentCount();
    for (int i = 0; i < nmembers; i++) {
      Component m = target.getComponent(i);
      if (m.isVisible()) {
        Dimension d = m.getPreferredSize();
        maxWidth = Math.max(d.width, maxWidth);
      }
    }
  }
  return maxWidth;
}
origin: org.microemu/microemu-javase-swing

public void layoutContainer(Container target) {
  Insets insets = target.getInsets();
  int count = target.getComponentCount();
  for (int i = 0; i < count; i++) {
    Component component = target.getComponent(i);
    if (component.isVisible()) {
      Rectangle r = getComponentBounds(component, true);
      component.setBounds(insets.left + r.x, insets.top + r.y, r.width, r.height);
    }
  }
}
origin: stackoverflow.com

return (popupMenu == null) ? 0 : popupMenu.getComponentCount();
return (popupMenu == null) ? null : popupMenu.getComponent(n);
origin: runelite/runelite

final int ncomponents = parent.getComponentCount();
int nrows = getRows();
int ncols = getColumns();
  final Component comp = parent.getComponent(i);
  final Dimension d = sizer.apply(comp);
final Insets insets = parent.getInsets();
return new Dimension(
  insets.left + insets.right + nw + (ncols - 1) * getHgap(),
  insets.top + insets.bottom + nh + (nrows - 1) * getVgap());
origin: crashinvaders/gdx-texture-packer-gui

public Dimension minimumLayoutSize (Container parent) {
  Dimension size = new Dimension();
  for (int i = 0, n = parent.getComponentCount(); i < n; i++) {
    Dimension min = parent.getComponent(i).getMinimumSize();
    size.width = Math.max(size.width, min.width);
    size.height = Math.max(size.height, min.height);
  }
  return size;
}
origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

private static int getMaximumWidth(Container target) {
  int maxWidth = 0;
  synchronized (target.getTreeLock()) {
    int nmembers = target.getComponentCount();
    for (int i = 0; i < nmembers; i++) {
      Component m = target.getComponent(i);
      if (m.isVisible()) {
        Dimension d = m.getPreferredSize();
        maxWidth = Math.max(d.width, maxWidth);
      }
    }
  }
  return maxWidth;
}
origin: igniterealtime/Openfire

/**
 * @return returns true if the component of one of its child has the focus
 */
public static boolean isAncestorOfFocusedComponent(Component c) {
  if (c.hasFocus()) {
    return true;
  } else {
    if (c instanceof Container) {
      Container cont = (Container) c;
      int n = cont.getComponentCount();
      for (int i = 0; i < n; i++) {
        Component child = cont.getComponent(i);
        if (isAncestorOfFocusedComponent(child))
          return true;
      }
    }
  }
  return false;
}
origin: net.java.abeille/abeille

/**
 * @param parent
 */
public void layoutContainer(Container parent) {
  Insets insets = parent.getInsets();
  for (int index = 0; index < parent.getComponentCount(); index++) {
    Component comp = parent.getComponent(index);
    comp.setLocation(insets.left, insets.top);
    comp.setSize(parent.getWidth() - insets.left - insets.right, parent.getHeight() - insets.top - insets.bottom);
  }
}
origin: runelite/runelite

final Insets insets = parent.getInsets();
final int ncomponents = parent.getComponentCount();
int nrows = getRows();
int ncols = getColumns();
  final Component comp = parent.getComponent(i);
  final Dimension d = comp.getPreferredSize();
  d.width = (int) (sw * d.width);
  d.height = (int) (sh * d.height);
      parent.getComponent(i).setBounds(x, y, w[c], h[r]);
origin: tahaemara/object-recognition-tensorflow

public Dimension minimumLayoutSize (Container parent) {
  Dimension size = new Dimension();
  for (int i = 0, n = parent.getComponentCount(); i < n; i++) {
    Dimension min = parent.getComponent(i).getMinimumSize();
    size.width = Math.max(size.width, min.width);
    size.height = Math.max(size.height, min.height);
  }
  return size;
}
origin: it.tidalwave.netbeans/it-tidalwave-netbeans-swing

 public void layoutContainer (final Container container) 
  {
   final int width = container.getWidth();
   final int height = container.getHeight();
   for (int i = 0; i < container.getComponentCount(); i++) 
    {
     final Component component = container.getComponent(i);
     final int x = (width - component.getWidth()) / 2;
     final int y = (height - component.getHeight()) / 2;
     component.setBounds(x, y, component.getPreferredSize().width, component.getPreferredSize().height);
    }
  }      
}        
origin: igniterealtime/Openfire

int n = cont.getComponentCount();
for (int i = 0; i < n; i++) {
  Component child = cont.getComponent(i);
  Component focused = getFocusableComponentOrChild(child, deepest);
  if (focused != null) {
origin: pengwei1024/AndroidSourceViewer

  @Override
  public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();
    int maxWidth = parent.getWidth() - (insets.left + insets.right);
    int count = parent.getComponentCount();
    int height = 0;
    int gap = padding;
    for (int i = 0; i < count; i++) {
      Component component = parent.getComponent(i);
      if (component.isVisible()) {
        Dimension size = component.getPreferredSize();
        component.setBounds(gap, height, maxWidth - gap * 2, size.height);
        height += size.height + gap * 2;
      }
    }
  }
}
origin: org.jclarion/clarion-runtime

@Override
public Dimension minimumLayoutSize(Container parent) 
{
  int maxHeight=0;
  int width=0;
  for (int scan=0;scan<parent.getComponentCount();scan++) {
    Component base = parent.getComponent(scan);
    Dimension pref = base.getMinimumSize();
    if (sizes[scan]>0) {
      width+=sizes[scan];
    } else {
      width-=sizes[scan];
    }
    if (pref.height>maxHeight) maxHeight=pref.height;
  }
  return new Dimension(width,maxHeight);
}
origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

private int getMaximumWidth (Container target) {
  int maxWidth = 0;
  synchronized (target.getTreeLock()) {
    int nmembers = target.getComponentCount();
    for (int i = 0 ; i < nmembers ; i++) {
      Component m = target.getComponent(i);
      if (m.isVisible ()) {
        Dimension d = m.getPreferredSize();
        maxWidth = Math.max(d.width, maxWidth);
      }
    }
  }
  return maxWidth;
}
origin: org.netbeans.api/org-openide-util-ui

/** Find a focus-traverable component.
* @param c the component to look in
* @return the same component if traversable, else a child component if present, else <code>null</code>
* @see Component#isFocusTraversable
*/
public static Component getFocusTraversableComponent(Component c) {
  if (c.isFocusable()) {
    return c;
  }
  if (!(c instanceof Container)) {
    return null;
  }
  int i;
  int k = ((Container) c).getComponentCount();
  for (i = 0; i < k; i++) {
    Component v = ((Container) c).getComponent(i);
    if (v != null) {
      return v;
    }
  }
  return null;
}

java.awtContainergetComponent

Javadoc

Gets the nth component in this container.

Popular methods of Container

  • add
    Adds the specified component to this container. This is a convenience method for #addImpl. This meth
  • setLayout
    Sets the layout manager for this container.
  • getComponents
    Gets all the components in this container.
  • getParent
  • getComponentCount
    Gets the number of components in this panel.
  • remove
    Removes the specified component from this container.
  • getWidth
  • getInsets
    Determines the insets of this container, which indicate the size of the container's border. A Frame
  • getSize
  • getHeight
  • repaint
  • setBackground
  • repaint,
  • setBackground,
  • getLayout,
  • validate,
  • getTreeLock,
  • removeAll,
  • getPreferredSize,
  • getBackground,
  • getBounds

Popular in Java

  • Updating database using SQL prepared statement
  • startActivity (Activity)
  • setContentView (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Table (org.hibernate.mapping)
    A relational table
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now