Java Code Examples for java.awt.Component#setPreferredSize()
The following examples show how to use
java.awt.Component#setPreferredSize() .
These examples are extracted from open source projects.
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 Project: jpexs-decompiler File: ListLayout.java License: GNU General Public License v3.0 | 6 votes |
@Override public void layoutContainer(Container parent) { Dimension dim = preferredLayoutSize(parent); Insets ins = parent.getInsets(); int top = ins.top; boolean first = true; for (Component c : parent.getComponents()) { if (!c.isVisible()) { continue; } if (!first) { top += border; } Dimension pref = c.getPreferredSize(); c.setPreferredSize(new Dimension(dim.width, pref.height)); c.setMinimumSize(new Dimension(dim.width, pref.height)); c.setBounds(0, top, dim.width, pref.height); top += pref.height; first = false; } }
Example 2
Source Project: openjdk-jdk9 File: XMBeanAttributes.java License: GNU General Public License v2.0 | 5 votes |
MaximizedCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 220) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 220)); } }
Example 3
Source Project: hottub File: XMBeanAttributes.java License: GNU General Public License v2.0 | 5 votes |
MaximizedCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 220) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 220)); } }
Example 4
Source Project: arcusplatform File: DeletePrompt.java License: Apache License 2.0 | 5 votes |
private void addInput(JPanel p, Component c, int inputSize, GridBagConstraints gbc) { gbc.gridx = 1; gbc.fill = inputSize > 0 ? GridBagConstraints.NONE : GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.weightx = inputSize > 0 ? 0 : 1; if (inputSize > 0) { c.setPreferredSize(new Dimension(inputSize, c.getPreferredSize().height)); c.setMinimumSize(c.getPreferredSize()); } p.add(c, gbc.clone()); }
Example 5
Source Project: arcusplatform File: BillingInformationPrompt.java License: Apache License 2.0 | 5 votes |
private void addInput(JPanel p, Component c, int inputSize, GridBagConstraints gbc) { gbc.gridx = 1; gbc.fill = inputSize > 0 ? GridBagConstraints.NONE : GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.weightx = inputSize > 0 ? 0 : 1; if (inputSize > 0) { c.setPreferredSize(new Dimension(inputSize, c.getPreferredSize().height)); c.setMinimumSize(c.getPreferredSize()); } p.add(c, gbc.clone()); }
Example 6
Source Project: arcusplatform File: AddPlacePrompt.java License: Apache License 2.0 | 5 votes |
private void addInput(JPanel p, Component c, int inputSize, GridBagConstraints gbc) { gbc.gridx = 1; gbc.fill = inputSize > 0 ? GridBagConstraints.NONE : GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.weightx = inputSize > 0 ? 0 : 1; if (inputSize > 0) { c.setPreferredSize(new Dimension(inputSize, c.getPreferredSize().height)); c.setMinimumSize(c.getPreferredSize()); } p.add(c, gbc.clone()); }
Example 7
Source Project: TencentKona-8 File: XMBeanNotifications.java License: GNU General Public License v2.0 | 5 votes |
UserDataCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 200) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 200)); } }
Example 8
Source Project: jdk8u-jdk File: XMBeanAttributes.java License: GNU General Public License v2.0 | 5 votes |
MaximizedCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 220) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 220)); } }
Example 9
Source Project: openjdk-8 File: XMBeanAttributes.java License: GNU General Public License v2.0 | 5 votes |
MaximizedCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 220) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 220)); } }
Example 10
Source Project: jdk8u60 File: XMBeanNotifications.java License: GNU General Public License v2.0 | 5 votes |
UserDataCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 200) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 200)); } }
Example 11
Source Project: jdk8u60 File: XMBeanAttributes.java License: GNU General Public License v2.0 | 5 votes |
MaximizedCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 220) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 220)); } }
Example 12
Source Project: visualvm File: XMBeanAttributes.java License: GNU General Public License v2.0 | 5 votes |
MaximizedCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 220) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 220)); } }
Example 13
Source Project: openjdk-jdk9 File: XMBeanNotifications.java License: GNU General Public License v2.0 | 5 votes |
UserDataCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 200) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 200)); } }
Example 14
Source Project: openjdk-jdk8u-backup File: XMBeanAttributes.java License: GNU General Public License v2.0 | 5 votes |
MaximizedCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 220) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 220)); } }
Example 15
Source Project: jdk8u_jdk File: XMBeanNotifications.java License: GNU General Public License v2.0 | 5 votes |
UserDataCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 200) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 200)); } }
Example 16
Source Project: openjdk-8-source File: XMBeanNotifications.java License: GNU General Public License v2.0 | 5 votes |
UserDataCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); if (d.getHeight() > 200) { comp.setPreferredSize(new Dimension((int) d.getWidth(), 200)); } }
Example 17
Source Project: openjdk-jdk9 File: ChangeWindowResizabiltyTest.java License: GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Robot robot = new Robot(); for(int i = 0; i < 10; i++) { Dialog dialog = new Dialog((Frame) null); dialog.setLocation(100, 100); Component panel = new Panel(); panel.setPreferredSize(new Dimension(200, 100)); dialog.add(panel); dialog.pack(); dialog.setVisible(true); robot.waitForIdle(); robot.delay(200); Point frameLoc = dialog.getLocationOnScreen(); Point contentLoc = panel.getLocationOnScreen(); System.out.println("Decor location " + frameLoc); System.out.println("Content location " + contentLoc); dialog.setResizable(false); robot.waitForIdle(); robot.delay(200); Point l = dialog.getLocationOnScreen(); if (!l.equals(frameLoc)) { dialog.dispose(); throw new RuntimeException("Decorated frame location moved " + "after setResizable(false)" + l); } l = panel.getLocationOnScreen(); if (!l.equals(contentLoc)) { dialog.dispose(); throw new RuntimeException("Content location moved after " + "setResizable(false)" + l); } if (panel.getLocationOnScreen().y < dialog.getLocationOnScreen().y + dialog.getInsets().top) { dialog.dispose(); throw new RuntimeException( "Wrong content position after setResizable(false)"); } dialog.setResizable(true); robot.waitForIdle(); robot.delay(200); l = dialog.getLocationOnScreen(); if (!l.equals(frameLoc)) { dialog.dispose(); throw new RuntimeException("Decorated frame location moved " + "after setResizable(true)" + l); } l = panel.getLocationOnScreen(); if (!l.equals(contentLoc)) { dialog.dispose(); throw new RuntimeException("Content location moved after " + "setResizable(true)" + l); } if (panel.getLocationOnScreen().y < dialog.getLocationOnScreen().y + dialog.getInsets().top) { dialog.dispose(); throw new RuntimeException( "Wrong content position after setResizable(true)"); } dialog.dispose(); } }
Example 18
Source Project: java-photoslibrary File: UIHelper.java License: Apache License 2.0 | 4 votes |
public static void setFixedSize(Component component, Dimension dimension) { component.setSize(dimension); component.setPreferredSize(dimension); component.setMaximumSize(dimension); component.setMinimumSize(dimension); }
Example 19
Source Project: netbeans File: HeapFragmentWalkerUI.java License: Apache License 2.0 | 4 votes |
private void unifyComponentsSize(Component c1, Component c2) { Dimension preferredSize = new Dimension(Math.max(c1.getPreferredSize().width, c2.getPreferredSize().width), Math.max(c1.getPreferredSize().height, c2.getPreferredSize().height)); c1.setPreferredSize(preferredSize); c2.setPreferredSize(preferredSize); }
Example 20
Source Project: gcs File: UIUtilities.java License: Mozilla Public License 2.0 | 2 votes |
/** * Sets a {@link Component}'s min, max & preferred sizes to a specific size. * * @param comp The {@link Component} to work on. * @param size The size to set the component to. */ public static void setOnlySize(Component comp, Dimension size) { comp.setMinimumSize(size); comp.setMaximumSize(size); comp.setPreferredSize(size); }