List of utility methods to do JComponent Size
Dimension | getSize(byte[] data) get Size ImageIcon ii = new ImageIcon(data); Image img = ii.getImage(); return new Dimension(img.getWidth(null), img.getHeight(null)); |
Dimension | getSize(Component c, int sizeflag) get Size if (c == null) { return new Dimension(0, 0); if (c instanceof JLabel) { View v = (View) ((JLabel) c).getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey); if (v != null) { switch (sizeflag) { case MIN: { ... |
Dimension | getValidatedSize(Component c, int sizeflag) get Validated Size return getValidatedSizes(c)[sizeflag];
|
Dimension | getViewableScreenSize() get Viewable Screen Size Dimension screenSizeExcludingToolbars = Toolkit.getDefaultToolkit().getScreenSize();
Insets insets = getSystemInsets();
screenSizeExcludingToolbars.width -= (insets.left + insets.right);
screenSizeExcludingToolbars.height -= (insets.top + insets.bottom);
return screenSizeExcludingToolbars;
|
Dimension | getVisibleSizeInViewport(Component c) get Visible Size In Viewport if (c.getParent() instanceof JViewport) { JViewport vp = (JViewport) c.getParent(); Dimension d = vp.getExtentSize(); if (vp.getParent() instanceof JScrollPane) { JScrollPane sp = (JScrollPane) vp.getParent(); if (sp.getVerticalScrollBar() != null && sp.getVerticalScrollBar().isVisible()) { d.width += sp.getVerticalScrollBar().getWidth(); if (sp.getHorizontalScrollBar() != null && sp.getHorizontalScrollBar().isVisible()) { d.height += sp.getHorizontalScrollBar().getHeight(); return d; } else { return null; |
Dimension | getWindowSize(JComponent start) return the size of the window return getTopAncestor(start).getSize();
|
JPanel | inset(Component c, int insetSizeHor, int insetSizeVert) Inset the given component by the given insetSize for horizontally and vertically. return doLayout(new JPanel(), new Component[] { c }, 1, WT_Y, WT_Y, null, null, new Insets(insetSizeVert, insetSizeHor, insetSizeVert, insetSizeHor)); |
boolean | isSmallSizeVariant(JComponent c) Returns true, if the component should use the small appearance. Font f = c.getFont(); if (f != null && f.getSize() <= 11) { return true; String p = (String) c.getClientProperty("JComponent.sizeVariant"); return p != null && p.equals("small"); |
void | makeEqualSize(JComponent reference, JComponent... others) make Equal Size if (reference == null) return; if (others == null) return; Dimension size = reference.getPreferredSize(); for (JComponent comp : others) { comp.setPreferredSize(size); |
void | makeSameSize(Component... components) make Same Size makeSameHeight(components); makeSameWidth(components); |