Java Code Examples for java.awt.Component#setMaximumSize()
The following examples show how to use
java.awt.Component#setMaximumSize() .
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: SimpleBoxFormBuilder.java From jdal with 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 File: DimensionEncapsulation.java From openjdk-jdk9 with 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 File: JPanelForTree.java From freeinternals with 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 4
Source File: DimensionEncapsulation.java From jdk8u_jdk with 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 File: SettingsPanel.java From visualvm with 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 6
Source File: DimensionEncapsulation.java From hottub with 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 7
Source File: DimensionEncapsulation.java From jdk8u-jdk with 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 8
Source File: DimensionEncapsulation.java From dragonwell8_jdk with 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 File: DimensionEncapsulation.java From openjdk-jdk8u-backup with 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 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 11
Source File: FormatSelector.java From netbeans with 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 12
Source File: DimensionEncapsulation.java From openjdk-jdk8u with 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 13
Source File: DimensionEncapsulation.java From jdk8u60 with 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 File: DimensionEncapsulation.java From TencentKona-8 with 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 15
Source File: UIHelper.java From java-photoslibrary with 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 File: TablePanel.java From rapidminer-studio with 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 File: UIUtilities.java From gcs with 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); }