List of usage examples for javax.swing JComponent setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:de.tud.kom.p2psim.impl.skynet.visualization.MetricsPlot.java
private void setSizeOfComponent(JComponent component, Dimension dim) { component.setMinimumSize(dim);/*from w ww. j ava2 s. c om*/ component.setMaximumSize(dim); component.setPreferredSize(dim); component.setSize(dim); }
From source file:com.limegroup.gnutella.gui.LicenseWindow.java
/** * Constructs a new LicenseWindow./*from ww w. j av a2s.co m*/ * @param license the License being displayed * @param urn the URN the license is validating against * @param listener a VerificationListener this license can forward * licenseVerified events to. */ private LicenseWindow(License license, URN urn, LimeXMLDocument document, VerificationListener listener, String keyValue) { super(GUIMediator.getAppFrame()); URN = urn; LICENSE = license; DETAILS = new JPanel(new GridBagLayout()); LISTENER = listener; KEY_VALUE = keyValue; DOCUMENT = document; setModal(false); setResizable(false); setTitle(getTitleString()); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JComponent pane = (JComponent) getContentPane(); GUIUtils.addHideAction(pane); pane.setPreferredSize(new Dimension(400, 230)); DETAILS.setPreferredSize(new Dimension(400, 210)); getContentPane().setLayout(new GridBagLayout()); constructDialog(getContentPane()); validate(); if (GUIMediator.isAppVisible()) setLocationRelativeTo(GUIMediator.getAppFrame()); else setLocation(GUIMediator.getScreenCenterPoint(this)); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopScrollBoxLayout.java
private void adjustViewPreferredSize() { JComponent view = DesktopComponentsHelper.getComposition(content); Dimension minimumSize = view.getMinimumSize(); Dimension preferredSize = null; switch (scrollBarPolicy) { case VERTICAL: preferredSize = new Dimension(impl.getViewport().getWidth(), minimumSize.height); break;/* www . j av a 2s . co m*/ case HORIZONTAL: preferredSize = new Dimension(minimumSize.width, impl.getViewport().getHeight()); break; case NONE: preferredSize = new Dimension(impl.getViewport().getWidth(), impl.getViewport().getHeight()); break; case BOTH: preferredSize = new Dimension(minimumSize.width, minimumSize.height); break; } view.setPreferredSize(preferredSize); requestRepaint(); }
From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java
private void computePreferredSizes() { for (String key : sizeGroups.keySet()) { int width = -1; int height = -1; for (JComponent component : sizeGroups.get(key)) { if (width < component.getPreferredSize().width) { width = component.getPreferredSize().width; }//from ww w . j a va 2 s . co m if (height < component.getPreferredSize().height) { height = component.getPreferredSize().height; } } // Sometimes the preferred width of a component can be too small to accommodate the contained text and in // that case the text is truncated and ellipsis will be shown. To fix it the width is increased. width += 2; for (JComponent component : sizeGroups.get(key)) { component.setMinimumSize(new Dimension(width, height)); component.setMaximumSize(new Dimension(width, height)); component.setPreferredSize(new Dimension(width, height)); } } sizeGroups.clear(); }
From source file:edu.ku.brc.af.ui.forms.MultiView.java
/** * Adds a viewable to the MultiView./*from ww w. ja va 2s. c o m*/ * @param viewable the Viewable to be added * @param name the name of the view to be added * @return true if it was added, false if name conflicts */ protected boolean add(final Viewable viewable, final String name) { if (viewMapByName.get(name) != null) { log.error("Adding a Viewable by a name that is already used[" + name + "]"); return false; } // else viewable.setCellName(cellName); viewMapByName.put(name, viewable); // CallapsablePanel if (separator != null) { cardPanel.add(viewable.getUIComponent(), name); JComponent controllerPanel = viewable.getControllerPanel(); if (controllerPanel == null) { controllerPanel = new JPanel(); controllerPanel.setPreferredSize(new Dimension(0, 0)); } separator.addToSubPanel(controllerPanel, name); } else { add(viewable.getUIComponent(), name); } return true; }
From source file:org.bitbucket.mlopatkin.android.logviewer.widgets.UiHelper.java
public static void setWidths(JComponent component, int width) { Dimension dim = component.getPreferredSize(); dim.width = width;/*from w ww . ja v a 2 s . co m*/ component.setPreferredSize(dim); component.setMaximumSize(dim); component.setMinimumSize(dim); }
From source file:org.drugis.addis.gui.WelcomeDialog.java
private void setBorder(JComponent pane) { pane.setPreferredSize(new Dimension(TEXT_WIDTH, COMP_HEIGHT)); pane.setBorder(ETCHED_BORDER);/*ww w. j av a2s . c o m*/ pane.setBackground(Color.white); }
From source file:org.esa.snap.ui.tooladapter.dialogs.ToolParameterEditorDialog.java
private JComponent addBoolPropertyEditor(JPanel parent, String label, String propertyName, Boolean value, int line) { parent.add(new JLabel(label), getConstraints(line, 1, 1)); PropertyDescriptor propertyDescriptor = container.getDescriptor(propertyName); CheckBoxEditor boolEditor = new CheckBoxEditor(); JComponent editorComponent = boolEditor.createEditorComponent(propertyDescriptor, valuesContext); ((JCheckBox) editorComponent).setSelected(value); editorComponent.setPreferredSize(new Dimension(30, 30)); GridBagConstraints constraints = getConstraints(line, 0, 1); constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.LINE_END; parent.add(editorComponent, constraints); return editorComponent; }
From source file:org.freeplane.view.swing.features.filepreview.AudioViewerFactory.java
public void setFinalViewerSize(final JComponent viewer, final Dimension size) { viewer.setPreferredSize(size); // ((BitmapViewerComponent) viewer).setScaleEnabled(true); }
From source file:org.freeplane.view.swing.features.filepreview.AudioViewerFactory.java
public void setDraftViewerSize(JComponent viewer, Dimension size) { viewer.setPreferredSize(size); // ((BitmapViewerComponent) viewer).setScaleEnabled(false); }