Java Code Examples for java.awt.Component#setMaximumSize()
The following examples show how to use
java.awt.Component#setMaximumSize() .
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: jdal File: SimpleBoxFormBuilder.java License: Apache License 2.0 | 6 votes |
/** * Add a component to Form at position pointer by cursor, * Increments cursor by one. * @param c Component to add */ public void add(Component c) { if (debug) { if (c instanceof JComponent) ((JComponent) c).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY)); } addBox(c); if (rowHeight < Short.MAX_VALUE) { Dimension d = c.getPreferredSize(); d.height = rowHeight; c.setPreferredSize(d); c.setMinimumSize(d); if (!c.isMaximumSizeSet() || c.getMaximumSize().getHeight() > rowHeight) { c.setMaximumSize(new Dimension(Short.MAX_VALUE, rowHeight)); } } }
Example 2
Source Project: dragonwell8_jdk File: DimensionEncapsulation.java License: GNU General Public License v2.0 | 5 votes |
public void runTest(final Component c) { try { test(c); c.setMinimumSize(new Dimension(100, 10)); c.setMaximumSize(new Dimension(200, 20)); c.setPreferredSize(new Dimension(300, 30)); test(c); } catch (final Throwable ignored) { failures.add(c); } }
Example 3
Source Project: TencentKona-8 File: DimensionEncapsulation.java License: GNU General Public License v2.0 | 5 votes |
public void runTest(final Component c) { try { test(c); c.setMinimumSize(new Dimension(100, 10)); c.setMaximumSize(new Dimension(200, 20)); c.setPreferredSize(new Dimension(300, 30)); test(c); } catch (final Throwable ignored) { failures.add(c); } }
Example 4
Source Project: jdk8u60 File: DimensionEncapsulation.java License: GNU General Public License v2.0 | 5 votes |
public void runTest(final Component c) { try { test(c); c.setMinimumSize(new Dimension(100, 10)); c.setMaximumSize(new Dimension(200, 20)); c.setPreferredSize(new Dimension(300, 30)); test(c); } catch (final Throwable ignored) { failures.add(c); } }
Example 5
Source Project: openjdk-jdk8u File: DimensionEncapsulation.java License: GNU General Public License v2.0 | 5 votes |
public void runTest(final Component c) { try { test(c); c.setMinimumSize(new Dimension(100, 10)); c.setMaximumSize(new Dimension(200, 20)); c.setPreferredSize(new Dimension(300, 30)); test(c); } catch (final Throwable ignored) { failures.add(c); } }
Example 6
Source Project: netbeans File: FormatSelector.java License: Apache License 2.0 | 5 votes |
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { FormatInfo info = (FormatInfo)value; Component comp = delegate.getListCellRendererComponent(list, info.getDisplayName(), index, isSelected, cellHasFocus); if (comp instanceof JComponent) { JComponent jcomp = (JComponent)comp; Border border = jcomp.getBorder(); if ((border != null) && (border.getBorderInsets(panel) != null)) { // Issue 161997 panel.setBorder(border); } else { panel.setBorder(BorderFactory.createEmptyBorder()); } panel.setOpaque(jcomp.isOpaque()); jcomp.setBorder(null); } panel.removeAll(); panel.setBackground(comp.getBackground()); // 1st column comp.setPreferredSize(null); Dimension prefSize = comp.getPreferredSize(); comp.setPreferredSize(new Dimension(width1, prefSize.height)); comp.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); panel.add(comp); panel.add(Box.createHorizontalStrut(5)); // 2nd column label.setText(info.getExample()); label.setForeground(comp.getForeground()); label.setFont(comp.getFont()); label.setPreferredSize(null); prefSize = label.getPreferredSize(); label.setPreferredSize(new Dimension(width2, prefSize.height)); label.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); panel.add(label); return panel; }
Example 7
Source Project: netbeans File: SettingsPanel.java License: 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 8
Source Project: openjdk-jdk8u-backup File: DimensionEncapsulation.java License: GNU General Public License v2.0 | 5 votes |
public void runTest(final Component c) { try { test(c); c.setMinimumSize(new Dimension(100, 10)); c.setMaximumSize(new Dimension(200, 20)); c.setPreferredSize(new Dimension(300, 30)); test(c); } catch (final Throwable ignored) { failures.add(c); } }
Example 9
Source Project: openjdk-jdk9 File: DimensionEncapsulation.java License: GNU General Public License v2.0 | 5 votes |
public void runTest(final Component c) { try { test(c); c.setMinimumSize(new Dimension(100, 10)); c.setMaximumSize(new Dimension(200, 20)); c.setPreferredSize(new Dimension(300, 30)); test(c); } catch (final Throwable ignored) { failures.add(c); } }
Example 10
Source Project: jdk8u-jdk File: DimensionEncapsulation.java License: GNU General Public License v2.0 | 5 votes |
public void runTest(final Component c) { try { test(c); c.setMinimumSize(new Dimension(100, 10)); c.setMaximumSize(new Dimension(200, 20)); c.setPreferredSize(new Dimension(300, 30)); test(c); } catch (final Throwable ignored) { failures.add(c); } }
Example 11
Source Project: hottub File: DimensionEncapsulation.java License: GNU General Public License v2.0 | 5 votes |
public void runTest(final Component c) { try { test(c); c.setMinimumSize(new Dimension(100, 10)); c.setMaximumSize(new Dimension(200, 20)); c.setPreferredSize(new Dimension(300, 30)); test(c); } catch (final Throwable ignored) { failures.add(c); } }
Example 12
Source Project: visualvm File: SettingsPanel.java License: GNU General Public License v2.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 13
Source Project: jdk8u_jdk File: DimensionEncapsulation.java License: GNU General Public License v2.0 | 5 votes |
public void runTest(final Component c) { try { test(c); c.setMinimumSize(new Dimension(100, 10)); c.setMaximumSize(new Dimension(200, 20)); c.setPreferredSize(new Dimension(300, 30)); test(c); } catch (final Throwable ignored) { failures.add(c); } }
Example 14
Source Project: freeinternals File: JPanelForTree.java License: Apache License 2.0 | 5 votes |
private void layoutComponents() { this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); final JPanel panelToolbar = new JPanel(); panelToolbar.setLayout(new BoxLayout(panelToolbar, BoxLayout.X_AXIS)); panelToolbar.add(this.toolbar); final Component glue = Box.createGlue(); glue.setMaximumSize(new Dimension(Short.MAX_VALUE, this.toolbar.getHeight())); panelToolbar.add(glue); final JPanel panelToolbarTree = new JPanel(); panelToolbarTree.setLayout(new BoxLayout(panelToolbarTree, BoxLayout.Y_AXIS)); panelToolbarTree.add(panelToolbar); panelToolbarTree.add(new JScrollPane(this.tree)); this.editorPaneDescription = new JEditorPane(); this.editorPaneDescription.setContentType("text/html"); this.editorPaneDescription.setEditable(false); this.editorPaneDescription.setPreferredSize(EDITOR_DEFAULT_SIZE); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(panelToolbarTree); splitPane.setBottomComponent(new JScrollPane(this.editorPaneDescription)); splitPane.setResizeWeight(1.0); this.add(splitPane, BorderLayout.CENTER); }
Example 15
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 16
Source Project: rapidminer-studio File: TablePanel.java License: GNU Affero General Public License v3.0 | 4 votes |
/** * Updates the component in the specified cell. * * @param rowIndex * @param columnIndex */ private void updateComponent(int rowIndex, int columnIndex) { Pair<Integer, Integer> key = new Pair<>(rowIndex, columnIndex); // remove old component Component oldComponent = mapOfComponents.get(key); if (oldComponent != null) { innerPanel.remove(oldComponent); } // add updated component to panel instead Component updatedComponent = createComponentForCell(rowIndex, columnIndex); // add dimension constraint (if applicable) if (isConstraintsUsed()) { updatedComponent.setMinimumSize(constraints[columnIndex]); updatedComponent.setMaximumSize(constraints[columnIndex]); updatedComponent.setPreferredSize(constraints[columnIndex]); } if (isConstraintsUsed()) { gbc.weightx = 0.0; } else { if (Collection.class.isAssignableFrom(model.getColumnClass(columnIndex))) { gbc.weightx = 0.1; } else { gbc.weightx = 1.0 / model.getColumnCount(); } } gbc.weighty = 0.0; if (isConstraintsUsed() && fillerMode == FillerMode.NONE) { gbc.fill = GridBagConstraints.VERTICAL; } else { gbc.fill = GridBagConstraints.BOTH; } gbc.gridx = columnIndex; gbc.gridy = rowIndex; innerPanel.add(updatedComponent, gbc); innerPanel.revalidate(); innerPanel.repaint(); mapOfComponents.put(key, updatedComponent); }
Example 17
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); }