Java Code Examples for java.awt.Component#setMinimumSize()
The following examples show how to use
java.awt.Component#setMinimumSize() .
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: 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 3
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 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: 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 8
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 9
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 10
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 11
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 12
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 13
Source Project: visualvm File: ProfilerPopupMenu.java License: GNU General Public License v2.0 | 5 votes |
public void add(Component comp, Object constraints) { if (forceBackground && !UIUtils.isOracleLookAndFeel() && comp instanceof JComponent) ((JComponent)comp).setOpaque(false); if (forceBackground && !UIUtils.isNimbusLookAndFeel()) comp.setForeground(getForeground()); comp.setMinimumSize(comp.getPreferredSize()); super.add(comp, constraints); }
Example 14
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 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: netbeans File: ProfilerPopupMenu.java License: Apache License 2.0 | 4 votes |
public void add(Component comp, Object constraints) { if (forceBackground && !UIUtils.isOracleLookAndFeel() && comp instanceof JComponent) ((JComponent)comp).setOpaque(false); comp.setMinimumSize(comp.getPreferredSize()); super.add(comp, constraints); }
Example 17
Source Project: netbeans File: BookmarksView.java License: Apache License 2.0 | 4 votes |
private static void fixScrollPaneinSplitPaneJDKIssue(Component c) { c.setMinimumSize(new Dimension(10, 10)); // Workaround for JSplitPane-containing-JScrollPane JDK bug }
Example 18
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 19
Source Project: wpcleaner File: InformationWindow.java License: Apache License 2.0 | 4 votes |
/** * @return Window components. */ @Override protected Component createComponents() { JPanel panel = new JPanel(new GridBagLayout()); // Initialize constraints GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridheight = 1; constraints.gridwidth = 1; constraints.gridx = 0; constraints.gridy = 0; constraints.insets = new Insets(2, 2, 2, 2); constraints.ipadx = 0; constraints.ipady = 0; constraints.weightx = 0; constraints.weighty = 0; // Title lblTitle = Utilities.createJLabel(title); lblTitle.setHorizontalAlignment(SwingConstants.LEADING); constraints.gridx = 0; constraints.weightx = 0; panel.add(lblTitle, constraints); constraints.gridy++; // Information Component component = null; if (html) { textInformation = HTMLPane.createHTMLPane(null); component = textInformation; } else { textPane = new JTextPane(); textPane.setEditable(false); component = textPane; } JScrollPane scrollPane = new JScrollPane(component); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); component = scrollPane; component.setPreferredSize(new Dimension(500, 500)); component.setMinimumSize(new Dimension(100, 100)); lblTitle.setLabelFor(component); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 0; constraints.weighty = 1; constraints.weightx = 1; panel.add(component, constraints); constraints.gridy++; // Buttons JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonClose = ActionDispose.createButton(getParentComponent(), true, false); buttonPanel.add(buttonClose); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.weightx = 1; constraints.weighty = 0; panel.add(buttonPanel, constraints); constraints.gridy++; return panel; }
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); }