/** 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; }
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)) { int miny = Integer.MIN_VALUE; boolean found_one = false; int n = target.getComponentCount(); 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);
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();
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; }
super.addImpl(comp, constraints, index); if(maximumVisibleRows < getComponentCount()-1) { getScrollBar().setVisible(true); if(maximumVisibleRows >= getComponentCount()-1) { getScrollBar().setVisible(false); for(Component comp : getComponents()) { if(!(comp instanceof JScrollBar)) { Dimension preferredSize = comp.getPreferredSize(); width = Math.max(width, preferredSize.width); if(unit < 0){ Dimension pref = comp.getPreferredSize(); dim.width = Math.max(dim.width, pref.width); dim.height += pref.height; Insets insets = parent.getInsets(); dim.height = Math.min(dim.height + insets.top + insets.bottom, visibleAmount); Insets insets = parent.getInsets(); dim.height = Math.min(dim.height + insets.top + insets.bottom, visibleAmount); Insets insets = parent.getInsets();
@Override public Dimension preferredLayoutSize(Container parent) { if (parent.isPreferredSizeSet() || parent.getComponentCount() == 0) { return parent.getPreferredSize(); } else { int x = -1, y = -1; for (Component child : parent.getComponents()) { Dimension dim = child.getPreferredSize(); x = Math.max(dim.width, x); y = Math.max(dim.height, y); } return new Dimension(x, y); } }
return (popupMenu == null) ? 0 : popupMenu.getComponentCount(); return (popupMenu == null) ? null : popupMenu.getComponent(n);
@Override public Dimension minimumLayoutSize(Container parent) { Dimension dim = new Dimension(0, 0); int nComps = parent.getComponentCount(); //Always add the container's insets! Insets insets = parent.getInsets(); dim.width = minWidth + insets.left + insets.right; dim.height = minHeight + insets.top + insets.bottom; sizeUnknown = false; return dim; }
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]);
public Dimension preferredLayoutSize (Container parent) { Dimension size = new Dimension(); for (int i = 0, n = parent.getComponentCount(); i < n; i++) { Dimension pref = parent.getComponent(i).getPreferredSize(); size.width = Math.max(size.width, pref.width); size.height = Math.max(size.height, pref.height); } return size; }
/** * @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; }
private Dimension getLayoutSize(Container parent, int type) { int width = 0; int height = 0; int components = parent.getComponentCount(); int visibleComponents = getVisibleComponents(parent); for (int i = 0; i < components; i++) { Component component = parent.getComponent(i); if (!component.isVisible()) { continue; } Dimension d = getDimension(component, type); if (axis == X_AXIS) { width += d.width; height = Math.max(height, d.height); } else { width = Math.max(width, d.width); height += d.height; } } Insets insets = parent.getInsets(); int totalGap = ((visibleComponents - 1) * gap) + (2 * borderGap); if (axis == X_AXIS) { width += insets.left + insets.right + totalGap; height += insets.top + insets.bottom; } else { width += insets.left + insets.right; height += insets.top + insets.bottom + totalGap; } return new Dimension(width, height); }
@Override public Dimension preferredLayoutSize(Container parent) { if (parent.isPreferredSizeSet() || parent.getComponentCount() == 0) { return parent.getPreferredSize(); } else { int x = -1, y = -1; for (Component child : parent.getComponents()) { Dimension dim = child.getPreferredSize(); x = Math.max(dim.width, x); y = Math.max(dim.height, y); } return new Dimension(x, y); } }
@Override public Dimension preferredLayoutSize(Container parent) { Dimension dim = new Dimension(0, 0); int nComps = parent.getComponentCount(); setSizes(parent); //Always add the container's insets! Insets insets = parent.getInsets(); dim.width = preferredWidth + insets.left + insets.right; dim.height = preferredHeight + insets.top + insets.bottom; sizeUnknown = false; return dim; }
@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; } } } }
public Dimension preferredLayoutSize (Container parent) { Dimension size = new Dimension(); for (int i = 0, n = parent.getComponentCount(); i < n; i++) { Dimension pref = parent.getComponent(i).getPreferredSize(); size.width = Math.max(size.width, pref.width); size.height = Math.max(size.height, pref.height); } return size; }
int n = cont.getComponentCount(); for (int i = 0; i < n; i++) { Component child = cont.getComponent(i); Component focused = getFocusableComponentOrChild(child, deepest); if (focused != null) {
synchronized (target.getTreeLock()) { Dimension dim = new Dimension(0, 0); int nmembers = target.getComponentCount(); Component m = target.getComponent(i); Insets insets = target.getInsets(); dim.width += (insets.left + insets.right + (getHgap() * 2)); dim.height += (insets.top + insets.bottom + (getVgap() * 2));
@Override public Dimension preferredLayoutSize(Container target) { synchronized (target.getTreeLock()) { Dimension dim = new Dimension(0, 0); int count = target.getComponentCount(); for (int i = 0; i < count; i++) { Component m = target.getComponent(i); Dimension d = m.getPreferredSize(); dim.width = Math.max(dim.width, d.width); dim.height += d.height + padding; } Insets insets = target.getInsets(); dim.width += insets.left + insets.right + padding * 2; dim.height += insets.top + insets.bottom + padding * 2; return dim; } }
@Override public Dimension preferredLayoutSize(Container parent) { int maxHeight=0; int width=0; for (int scan=0;scan<parent.getComponentCount();scan++) { Component base = parent.getComponent(scan); Dimension pref = base.getPreferredSize(); if (sizes[scan]>0) { width+=sizes[scan]; } else { width-=sizes[scan]; } if (pref.height>maxHeight) maxHeight=pref.height; } return new Dimension(width,maxHeight); }