Java Code Examples for javax.swing.JComponent#getMaximumSize()
The following examples show how to use
javax.swing.JComponent#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: RowLayout.java From pumpernickel with MIT License | 6 votes |
int getMaximumHeight() { Row row = rows.get(rowIndex); int maxHeight = 0; for (int a = 0; a < row.componentListUnwrapped.size(); a++) { JComponent jc = row.componentListUnwrapped.get(a); if (jc != null && theoreticalBoundsTable.get(jc) != null) { int width = theoreticalBoundsTable.get(jc).width; Dimension d = getMaximumSize(jc, width); if (d == null) d = jc.getMaximumSize(); if (d != null) maxHeight = Math.max(maxHeight, d.height); } } return maxHeight; }
Example 2
Source File: RowLayout.java From pumpernickel with MIT License | 6 votes |
private int getMaximumExtraHeight(Row row, int[] columnWidths) { int maxExtraHeight = 0; for (int a = 0; a < row.columns.length; a++) { if (row.columns[a] != null) { int columnWidth = columnWidths[a]; for (int b = 0; b < row.columns[a].components.length; b++) { JComponent jc = row.columns[a].components[b]; ComponentConstraints c = row.columns[a].constraints[b]; if (jc != null && jc.isVisible() && c.verticalPriority == profile.maxVisiblePriority) { Dimension maxSize = getMaximumSize(jc, columnWidth); if (maxSize == null) maxSize = jc.getMaximumSize(); Dimension preferredSize = getPreferredSize(jc); maxExtraHeight = Math.max(maxExtraHeight, maxSize.height - preferredSize.height); } } } } return maxExtraHeight; }
Example 3
Source File: CompletionLayoutPopup.java From netbeans with Apache License 2.0 | 5 votes |
final Dimension getPreferredSize() { JComponent comp = getContentComponent(); if (comp == null) return new Dimension(0, 0); int screenWidth = Utilities.getUsableScreenBounds().width; Dimension maxSize = new Dimension((int) (screenWidth * MAX_COMPL_COVERAGE), comp.getMaximumSize().height); //set maximum part of screen covered setMaxSize(comp, maxSize); return comp.getPreferredSize(); }
Example 4
Source File: CompletionLayoutPopup.java From netbeans with Apache License 2.0 | 5 votes |
final Dimension getPreferredSize() { JComponent comp = getContentComponent(); if (comp == null) return new Dimension(0, 0); int screenWidth = Utilities.getUsableScreenBounds().width; Dimension maxSize = new Dimension((int) (screenWidth * MAX_COMPL_COVERAGE), comp.getMaximumSize().height); //set maximum part of screen covered setMaxSize(comp, maxSize); return comp.getPreferredSize(); }
Example 5
Source File: CompletionLayoutPopup.java From netbeans with Apache License 2.0 | 5 votes |
final Dimension getPreferredSize() { JComponent comp = getContentComponent(); if (comp == null) { return new Dimension(0, 0); } int screenWidth = Utilities.getUsableScreenBounds().width; Dimension maxSize = new Dimension((int) (screenWidth * MAX_COMPL_COVERAGE), comp.getMaximumSize().height); //set maximum part of screen covered setMaxSize(comp, maxSize); return comp.getPreferredSize(); }
Example 6
Source File: BERootPaneUI.java From beautyeye with Apache License 2.0 | 4 votes |
/** * Returns the maximum amount of space the layout can use. * * @param target the target * @return a Dimension object containing the layout's maximum size */ public Dimension maximumLayoutSize(Container target) { Dimension cpd, mbd, tpd; int cpWidth = Integer.MAX_VALUE; int cpHeight = Integer.MAX_VALUE; int mbWidth = Integer.MAX_VALUE; int mbHeight = Integer.MAX_VALUE; int tpWidth = Integer.MAX_VALUE; int tpHeight = Integer.MAX_VALUE; Insets i = target.getInsets(); JRootPane root = (JRootPane) target; if(root.getContentPane() != null) { cpd = root.getContentPane().getMaximumSize(); if (cpd != null) { cpWidth = cpd.width; cpHeight = cpd.height; } } if(root.getMenuBar() != null) { mbd = root.getMenuBar().getMaximumSize(); if (mbd != null) { mbWidth = mbd.width; mbHeight = mbd.height; } } if (root.getWindowDecorationStyle() != JRootPane.NONE && (root.getUI() instanceof BERootPaneUI)) { JComponent titlePane = ((BERootPaneUI)root.getUI()). getTitlePane(); if (titlePane != null) { tpd = titlePane.getMaximumSize(); if (tpd != null) { tpWidth = tpd.width; tpHeight = tpd.height; } } } int maxHeight = Math.max(Math.max(cpHeight, mbHeight), tpHeight); // Only overflows if 3 real non-MAX_VALUE heights, sum to > MAX_VALUE // Only will happen if sums to more than 2 billion units. Not likely. if (maxHeight != Integer.MAX_VALUE) { maxHeight = cpHeight + mbHeight + tpHeight + i.top + i.bottom; } int maxWidth = Math.max(Math.max(cpWidth, mbWidth), tpWidth); // Similar overflow comment as above if (maxWidth != Integer.MAX_VALUE) { maxWidth += i.left + i.right; } return new Dimension(maxWidth, maxHeight); }
Example 7
Source File: SeaGlassRootPaneUI.java From seaglass with Apache License 2.0 | 4 votes |
/** * Returns the maximum amount of space the layout can use. * * @param target the Container for which this layout manager is being * used * * @return a Dimension object containing the layout's maximum size */ public Dimension maximumLayoutSize(Container target) { Dimension cpd; Dimension mbd; Dimension tpd; int cpWidth = Integer.MAX_VALUE; int cpHeight = Integer.MAX_VALUE; int mbWidth = Integer.MAX_VALUE; int mbHeight = Integer.MAX_VALUE; int tpWidth = Integer.MAX_VALUE; int tpHeight = Integer.MAX_VALUE; Insets i = target.getInsets(); JRootPane root = (JRootPane) target; if (root.getContentPane() != null) { cpd = root.getContentPane().getMaximumSize(); if (cpd != null) { cpWidth = cpd.width; cpHeight = cpd.height; } } if (root.getJMenuBar() != null) { mbd = root.getJMenuBar().getMaximumSize(); if (mbd != null) { mbWidth = mbd.width; mbHeight = mbd.height; } } if (root.getWindowDecorationStyle() != JRootPane.NONE && (root.getUI() instanceof SeaGlassRootPaneUI)) { JComponent titlePane = ((SeaGlassRootPaneUI) root.getUI()).getTitlePane(); if (titlePane != null) { tpd = titlePane.getMaximumSize(); if (tpd != null) { tpWidth = tpd.width; tpHeight = tpd.height; } } } int maxHeight = Math.max(Math.max(cpHeight, mbHeight), tpHeight); // Only overflows if 3 real non-MAX_VALUE heights, sum to > MAX_VALUE // Only will happen if sums to more than 2 billion units. Not likely. if (maxHeight != Integer.MAX_VALUE) { maxHeight = cpHeight + mbHeight + tpHeight + i.top + i.bottom; } int maxWidth = Math.max(Math.max(cpWidth, mbWidth), tpWidth); // Similar overflow comment as above if (maxWidth != Integer.MAX_VALUE) { maxWidth += i.left + i.right; } return new Dimension(maxWidth, maxHeight); }
Example 8
Source File: AgeCalculator.java From astor with GNU General Public License v2.0 | 4 votes |
static JComponent fixedHeight(JComponent component) { Dimension dim = component.getMaximumSize(); dim.height = component.getPreferredSize().height; component.setMaximumSize(dim); return component; }
Example 9
Source File: AgeCalculator.java From astor with GNU General Public License v2.0 | 4 votes |
static JComponent fixedHeight(JComponent component) { Dimension dim = component.getMaximumSize(); dim.height = component.getPreferredSize().height; component.setMaximumSize(dim); return component; }
Example 10
Source File: LauncherFrame.java From usergrid with Apache License 2.0 | 4 votes |
public void setMaxWidth( JComponent jc, int width ) { Dimension max = jc.getMaximumSize(); max.width = width; jc.setMaximumSize( max ); }
Example 11
Source File: JUtils.java From CQL with GNU Affero General Public License v3.0 | 3 votes |
/** * Sets the maximum height of a JComponent to its preferred height, thereby * preventing it from being expanded. The component itself is returned, to allow * shortcuts such as: xyz.add(JUtils.fixHeight(component)). * * @param c the component to be height-fixed * @return the component */ public static JComponent fixHeight(JComponent c) { Dimension max = c.getMaximumSize(); max.height = c.getPreferredSize().height; c.setMaximumSize(max); return c; }
Example 12
Source File: JUtils.java From CQL with GNU Affero General Public License v3.0 | 3 votes |
/** * Sets the maximum width of a JComponent to its preferred width, thereby * preventing it from being expanded. The component itself is returned, to allow * shortcuts such as: xyz.add(JUtils.fixWidth(component)). * * @param c the component to be width-fixed * @return the component */ public static JComponent fixWidth(JComponent c) { Dimension max = c.getMaximumSize(); max.width = c.getPreferredSize().width; c.setMaximumSize(max); return c; }