Java Code Examples for java.awt.Component#getMaximumSize()
The following examples show how to use
java.awt.Component#getMaximumSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DimensionEncapsulation.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void test(final Component component) { final Dimension psize = component.getPreferredSize(); psize.width += 200; if (Objects.equals(psize, component.getPreferredSize())) { throw new RuntimeException("PreferredSize is wrong"); } final Dimension msize = component.getMaximumSize(); msize.width += 200; if (Objects.equals(msize, component.getMaximumSize())) { throw new RuntimeException("MaximumSize is wrong"); } final Dimension misize = component.getMinimumSize(); misize.width += 200; if (Objects.equals(misize, component.getMinimumSize())) { throw new RuntimeException("MinimumSize is wrong"); } }
Example 2
Source File: StyledSplitPaneUI.java From stendhal with GNU General Public License v2.0 | 6 votes |
@Override public int getMinimumDividerLocation(JSplitPane pane) { int leftMin = super.getMinimumDividerLocation(pane); Component second = pane.getRightComponent(); if ((second != null) && second.isVisible()) { Dimension paneSize = splitPane.getSize(); Dimension maxSize = second.getMaximumSize(); Insets insets = pane.getInsets(); if (pane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { leftMin = Math.max(leftMin, paneSize.width - insets.right - maxSize.width); } else { leftMin = Math.max(leftMin, paneSize.height - insets.bottom - maxSize.height); } /* * To avoid inconsistency with the maximum location, it would seem * reasonable to do: * * leftMin = Math.min(leftMin, getMaximumDividerLocation(pane)); * * however, the parent already calls getMinimumDividerLocation() * in getMaximumDividerLocation(), so that would be a good way * to get a stack overflow. */ } return leftMin; }
Example 3
Source File: StyledSplitPaneUI.java From stendhal with GNU General Public License v2.0 | 6 votes |
@Override public int getMaximumDividerLocation(JSplitPane pane) { int rightMax = super.getMaximumDividerLocation(pane); Component first = pane.getLeftComponent(); if ((first != null) && first.isVisible()) { Dimension maxSize = first.getMaximumSize(); Insets insets = pane.getInsets(); if (pane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { rightMax = Math.min(rightMax, maxSize.width + insets.left); } else { rightMax = Math.min(rightMax, maxSize.height + insets.top); } // Sanity check. Must be in this method, not in // getMinimumDividerLocation() (see below) rightMax = Math.max(rightMax, getMinimumDividerLocation(pane)); } return rightMax; }
Example 4
Source File: WindowSizeLimiter.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Invoked when the component's size changes. * * @param e * the event. */ public void componentResized( final ComponentEvent e ) { if ( e.getSource() == currentSource ) { return; } if ( e.getSource() instanceof Component ) { currentSource = e.getSource(); final Component c = (Component) e.getSource(); final Dimension d = c.getMaximumSize(); final Dimension s = c.getSize(); if ( s.width > d.width ) { s.width = d.width; } if ( s.height > d.height ) { s.height = d.height; } c.setSize( s ); currentSource = null; } }
Example 5
Source File: DimensionEncapsulation.java From hottub with GNU General Public License v2.0 | 6 votes |
public void test(final Component component) { final Dimension psize = component.getPreferredSize(); psize.width += 200; if (Objects.equals(psize, component.getPreferredSize())) { throw new RuntimeException("PreferredSize is wrong"); } final Dimension msize = component.getMaximumSize(); msize.width += 200; if (Objects.equals(msize, component.getMaximumSize())) { throw new RuntimeException("MaximumSize is wrong"); } final Dimension misize = component.getMinimumSize(); misize.width += 200; if (Objects.equals(misize, component.getMinimumSize())) { throw new RuntimeException("MinimumSize is wrong"); } }
Example 6
Source File: DimensionEncapsulation.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public void test(final Component component) { final Dimension psize = component.getPreferredSize(); psize.width += 200; if (Objects.equals(psize, component.getPreferredSize())) { throw new RuntimeException("PreferredSize is wrong"); } final Dimension msize = component.getMaximumSize(); msize.width += 200; if (Objects.equals(msize, component.getMaximumSize())) { throw new RuntimeException("MaximumSize is wrong"); } final Dimension misize = component.getMinimumSize(); misize.width += 200; if (Objects.equals(misize, component.getMinimumSize())) { throw new RuntimeException("MinimumSize is wrong"); } }
Example 7
Source File: DimensionEncapsulation.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void test(final Component component) { final Dimension psize = component.getPreferredSize(); psize.width += 200; if (Objects.equals(psize, component.getPreferredSize())) { throw new RuntimeException("PreferredSize is wrong"); } final Dimension msize = component.getMaximumSize(); msize.width += 200; if (Objects.equals(msize, component.getMaximumSize())) { throw new RuntimeException("MaximumSize is wrong"); } final Dimension misize = component.getMinimumSize(); misize.width += 200; if (Objects.equals(misize, component.getMinimumSize())) { throw new RuntimeException("MinimumSize is wrong"); } }
Example 8
Source File: DimensionEncapsulation.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void test(final Component component) { final Dimension psize = component.getPreferredSize(); psize.width += 200; if (Objects.equals(psize, component.getPreferredSize())) { throw new RuntimeException("PreferredSize is wrong"); } final Dimension msize = component.getMaximumSize(); msize.width += 200; if (Objects.equals(msize, component.getMaximumSize())) { throw new RuntimeException("MaximumSize is wrong"); } final Dimension misize = component.getMinimumSize(); misize.width += 200; if (Objects.equals(misize, component.getMinimumSize())) { throw new RuntimeException("MinimumSize is wrong"); } }
Example 9
Source File: DimensionEncapsulation.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void test(final Component component) { final Dimension psize = component.getPreferredSize(); psize.width += 200; if (Objects.equals(psize, component.getPreferredSize())) { throw new RuntimeException("PreferredSize is wrong"); } final Dimension msize = component.getMaximumSize(); msize.width += 200; if (Objects.equals(msize, component.getMaximumSize())) { throw new RuntimeException("MaximumSize is wrong"); } final Dimension misize = component.getMinimumSize(); misize.width += 200; if (Objects.equals(misize, component.getMinimumSize())) { throw new RuntimeException("MinimumSize is wrong"); } }
Example 10
Source File: DimensionEncapsulation.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void test(final Component component) { final Dimension psize = component.getPreferredSize(); psize.width += 200; if (Objects.equals(psize, component.getPreferredSize())) { throw new RuntimeException("PreferredSize is wrong"); } final Dimension msize = component.getMaximumSize(); msize.width += 200; if (Objects.equals(msize, component.getMaximumSize())) { throw new RuntimeException("MaximumSize is wrong"); } final Dimension misize = component.getMinimumSize(); misize.width += 200; if (Objects.equals(misize, component.getMinimumSize())) { throw new RuntimeException("MinimumSize is wrong"); } }
Example 11
Source File: DimensionEncapsulation.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void test(final Component component) { final Dimension psize = component.getPreferredSize(); psize.width += 200; if (Objects.equals(psize, component.getPreferredSize())) { throw new RuntimeException("PreferredSize is wrong"); } final Dimension msize = component.getMaximumSize(); msize.width += 200; if (Objects.equals(msize, component.getMaximumSize())) { throw new RuntimeException("MaximumSize is wrong"); } final Dimension misize = component.getMinimumSize(); misize.width += 200; if (Objects.equals(misize, component.getMinimumSize())) { throw new RuntimeException("MinimumSize is wrong"); } }
Example 12
Source File: DimensionEncapsulation.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public void test(final Component component) { final Dimension psize = component.getPreferredSize(); psize.width += 200; if (Objects.equals(psize, component.getPreferredSize())) { throw new RuntimeException("PreferredSize is wrong"); } final Dimension msize = component.getMaximumSize(); msize.width += 200; if (Objects.equals(msize, component.getMaximumSize())) { throw new RuntimeException("MaximumSize is wrong"); } final Dimension misize = component.getMinimumSize(); misize.width += 200; if (Objects.equals(misize, component.getMinimumSize())) { throw new RuntimeException("MinimumSize is wrong"); } }
Example 13
Source File: VerticalFlowLayout.java From netbeans with Apache License 2.0 | 5 votes |
private Dimension computeDimension(Container parent, int type) { Insets insets = parent.getInsets(); int x = insets.left; int y = insets.top; int columnWidth = 0; // int limitHeight = parent.getHeight() - insets.bottom; int maxY = 0; for (Component c : this.components) { if (c.isVisible()) { Dimension d; switch (type) { case 0: d = c.getPreferredSize(); break; case 1: d = c.getMinimumSize(); break; default: d = c.getMaximumSize(); break; } columnWidth = Math.max(columnWidth, d.width); /* if (limitHeight != 0 && y + d.height >= limitHeight) { x += columnWidth + this.hgap; y = insets.top; columnWidth = d.width; } */ y += d.height; maxY = Math.max(y, maxY); y += this.vgap; } } x += columnWidth; return new Dimension(x, maxY); }
Example 14
Source File: SettingsPanel.java From netbeans with Apache License 2.0 | 5 votes |
private static int defaultHeight() { if (DEFAULT_HEIGHT == -1) { JPanel ref = new JPanel(null); ref.setLayout(new BoxLayout(ref, BoxLayout.LINE_AXIS)); ref.setOpaque(false); ref.add(new JLabel("XXX")); // NOI18N ref.add(new JButton("XXX")); // NOI18N ref.add(new PopupButton("XXX")); // NOI18N ref.add(new JCheckBox("XXX")); // NOI18N ref.add(new JRadioButton("XXX")); // NOI18N ref.add(new JTextField("XXX")); // NOI18N ref.add(new JExtendedSpinner(new SpinnerNumberModel(1, 1, 655535, 1))); Component separator = Box.createHorizontalStrut(1); Dimension d = separator.getMaximumSize(); d.height = 20; separator.setMaximumSize(d); ref.add(separator); DEFAULT_HEIGHT = ref.getPreferredSize().height; } return DEFAULT_HEIGHT; }
Example 15
Source File: SwingToolkit.java From gdx-texture-packer-gui with Apache License 2.0 | 4 votes |
public float getMaxHeight (Component widget) { return widget.getMaximumSize().height; }
Example 16
Source File: SwingToolkit.java From tablelayout with BSD 3-Clause "New" or "Revised" License | 4 votes |
public float getMaxWidth (Component widget) { return widget.getMaximumSize().width; }
Example 17
Source File: FilterBar.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void layoutContainer(Container target) { synchronized (target.getTreeLock()) { Insets insets = target.getInsets(); int maxwidth = target.getWidth() - (insets.left + insets.right + getHgap() * 2); int nmembers = target.getComponentCount(); int x = 0; int y = insets.top + getVgap(); int rowh = 0; int start = 0; boolean ltr = target.getComponentOrientation().isLeftToRight(); SizeRequirements[] xChildren = new SizeRequirements[nmembers]; SizeRequirements[] yChildren = new SizeRequirements[nmembers]; for (int i = 0; i < nmembers; i++) { Component c = target.getComponent(i); if (!c.isVisible()) { xChildren[i] = new SizeRequirements(0, 0, 0, c.getAlignmentX()); yChildren[i] = new SizeRequirements(0, 0, 0, c.getAlignmentY()); } else { Dimension min = c.getMinimumSize(); Dimension typ = c.getPreferredSize(); Dimension max = c.getMaximumSize(); xChildren[i] = new SizeRequirements(min.width, typ.width, max.width, c.getAlignmentX()); yChildren[i] = new SizeRequirements(min.height, typ.height, max.height, c.getAlignmentY()); if ((x == 0) || ((x + typ.width) <= maxwidth)) { if (x > 0) { x += getHgap(); } x += typ.width; rowh = Math.max(rowh, typ.height); } else { layoutComponents(target, insets.left + getHgap(), y, maxwidth, rowh, xChildren, yChildren, start, i, ltr); x = typ.width; y += getVgap() + rowh; rowh = typ.height; start = i; } } } layoutComponents(target, insets.left + getHgap(), y, maxwidth, rowh, xChildren, yChildren, start, nmembers, ltr); } }
Example 18
Source File: PrecisionLayoutData.java From gcs with Mozilla Public License 2.0 | 4 votes |
void computeSize(Scale scale, Component component, int wHint, int hHint, boolean useMinimumSize) { int scaledMinWidth = scale.scale(mMinWidth); int scaledMinHeight = scale.scale(mMinHeight); Dimension size; if (wHint != DEFAULT || hHint != DEFAULT) { size = component.getMinimumSize(); mCacheMinWidth = mMinWidth == DEFAULT ? size.width : scaledMinWidth; if (wHint != DEFAULT && wHint < mCacheMinWidth) { wHint = mCacheMinWidth; } int minHeight = mMinHeight == DEFAULT ? size.height : scaledMinHeight; if (hHint != DEFAULT && hHint < minHeight) { hHint = minHeight; } size = component.getMaximumSize(); if (wHint != DEFAULT && wHint > size.width) { wHint = size.width; } if (hHint != DEFAULT && hHint > size.height) { hHint = size.height; } } if (useMinimumSize) { size = component.getMinimumSize(); mCacheMinWidth = mMinWidth == DEFAULT ? size.width : scaledMinWidth; } else { size = component.getPreferredSize(); } if (mWidthHint != DEFAULT) { size.width = scale.scale(mWidthHint); } if (mMinWidth != DEFAULT && size.width < scaledMinWidth) { size.width = scaledMinWidth; } if (mHeightHint != DEFAULT) { size.height = scale.scale(mHeightHint); } if (mMinHeight != DEFAULT && size.height < scaledMinHeight) { size.height = scaledMinHeight; } if (wHint != DEFAULT) { size.width = wHint; } if (hHint != DEFAULT) { size.height = hHint; } mCacheWidth = size.width; mCacheHeight = size.height; }
Example 19
Source File: SwingToolkit.java From tablelayout with BSD 3-Clause "New" or "Revised" License | 4 votes |
public float getMaxHeight (Component widget) { return widget.getMaximumSize().height; }
Example 20
Source File: SwingToolkit.java From object-recognition-tensorflow with Apache License 2.0 | 4 votes |
public float getMaxWidth (Component widget) { return widget.getMaximumSize().width; }