Java Code Examples for javax.swing.JComponent#setPreferredSize()

The following examples show how to use javax.swing.JComponent#setPreferredSize() . 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: AbstractAdapterEditor.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
JComponent addValidatedTextField(JPanel parent, TextFieldEditor textEditor, String labelText, String propertyName, String validatorRegex) {
    if(validatorRegex == null || validatorRegex.isEmpty()){
        return addTextField(parent, textEditor, labelText, propertyName, false, null);
    } else {
        JLabel jLabel = new JLabel(labelText);
        parent.add(jLabel);
        PropertyDescriptor propertyDescriptor = propertyContainer.getDescriptor(propertyName);
        propertyDescriptor.setValidator(new PatternValidator(Pattern.compile(validatorRegex)));
        JComponent editorComponent = textEditor.createEditorComponent(propertyDescriptor, bindingContext);
        UIUtils.addPromptSupport(editorComponent, "enter " + labelText.toLowerCase().replace(":", "") + " here");
        editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight));
        editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight));
        jLabel.setLabelFor(editorComponent);
        parent.add(editorComponent);
        return editorComponent;
    }
}
 
Example 2
Source File: MergedMoleculesPopUp.java    From thunderstorm with GNU General Public License v3.0 6 votes vote down vote up
public MergedMoleculesPopUp(JTable parent, int row, int col, List<Molecule> molecules) {
    GenericTableModel model = new GenericTableModel();
    for(Molecule mol : molecules) {
        model.addRow(mol);
    }
    MoleculeDescriptor header = model.cloneDescriptor();
    header.removeParam(MoleculeDescriptor.LABEL_DETECTIONS);
    model.setDescriptor(header);
    //
    JComponent mergedMoleculesTable = new JScrollPane(new JTable(model));
    mergedMoleculesTable.setPreferredSize(new Dimension(450, 250));
    //
    new TableCellBalloonTip(parent, mergedMoleculesTable, row, col,
            new RoundedBalloonStyle(5, 10, Color.LIGHT_GRAY, Color.BLUE),
            new RightBelowPositioner(10, 10), BalloonTip.getDefaultCloseButton());
}
 
Example 3
Source File: TemplateIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected WizardDescriptor.Panel[] createPanels(Project project, TemplateWizard wiz) {
    Sources sources = (Sources) ProjectUtils.getSources(project);
    SourceGroup[] sourceGroups1 = sources.getSourceGroups(WebProjectConstants.TYPE_DOC_ROOT);
    SourceGroup[] sourceGroups;
    if (sourceGroups1.length == 0) {
        sourceGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    } else if (sourceGroups1.length == 1) {
        sourceGroups = new SourceGroup[]{sourceGroups1[0], sourceGroups1[0]};
    } else {
        sourceGroups = sourceGroups1;
    }

    templatePanel = new TemplatePanel(wiz);
    // creates simple wizard panel with bottom panel
    WizardDescriptor.Panel firstPanel = new JSFValidationPanel(
            Templates.buildSimpleTargetChooser(project, sourceGroups).bottomPanel(templatePanel).create());
    JComponent c = (JComponent) firstPanel.getComponent();
    Dimension d = c.getPreferredSize();
    d.setSize(d.getWidth(), d.getHeight() + 65);
    c.setPreferredSize(d);
    return new WizardDescriptor.Panel[]{
        firstPanel
    };
}
 
Example 4
Source File: AbstractAdapterEditor.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
JComponent addComboField(JPanel parent, String labelText, String propertyName, boolean isRequired, boolean isEditable) {
    PropertyDescriptor propertyDescriptor = propertyContainer.getDescriptor(propertyName);
    propertyDescriptor.setNotEmpty(isRequired);
    PropertyEditor editor = PropertyEditorRegistry.getInstance().findPropertyEditor(propertyDescriptor);
    JComponent editorComponent = editor.createEditorComponent(propertyDescriptor, bindingContext);
    editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight));
    editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight));
    if (editorComponent instanceof JComboBox) {
        JComboBox comboBox = (JComboBox)editorComponent;
        comboBox.setEditable(isEditable);
        comboBox.setEnabled(isEditable);
    }
    JLabel jLabel = new JLabel(labelText);
    parent.add(jLabel);
    jLabel.setLabelFor(editorComponent);
    parent.add(editorComponent);
    return editorComponent;
}
 
Example 5
Source File: ExampleVisualizer.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
protected JComponent makeMainVisualizationComponent(Example example) {
	JComponent main;
	String[] columnNames = new String[] { "Attribute", "Value" };
	String[][] data = new String[exampleSet.getAttributes().allSize()][2];
	Iterator<Attribute> a = exampleSet.getAttributes().allAttributes();
	int counter = 0;
	while (a.hasNext()) {
		Attribute attribute = a.next();
		data[counter][0] = attribute.getName();
		data[counter][1] = getFormattedValue(example, attribute);
		counter++;
	}
	ExtendedJTable table = new ExtendedJTable();
	table.setDefaultEditor(Object.class, null);
	TableModel tableModel = new DefaultTableModel(data, columnNames);
	table.setRowHighlighting(true);
	table.setRowHeight(PropertyPanel.VALUE_CELL_EDITOR_HEIGHT);
	table.setModel(tableModel);
	main = new ExtendedJScrollPane(table);
	main.setBorder(null);
	int tableHeight = (int) (table.getPreferredSize().getHeight() + table.getTableHeader().getPreferredSize().getHeight()
			+ 5); // 5 for border
	if (tableHeight < main.getPreferredSize().getHeight()) {
		main.setPreferredSize(new Dimension((int) main.getPreferredSize().getWidth(), tableHeight));
	}
	return main;
}
 
Example 6
Source File: ToolAdapterEditorDialog.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JPanel createPreProcessingPanel() {
    final JPanel preProcessingPanel = new JPanel(new SpringLayout());

    PropertyDescriptor propertyDescriptor = propertyContainer.getDescriptor("preprocessorExternalTool");
    PropertyEditor editor = PropertyEditorRegistry.getInstance().findPropertyEditor(propertyDescriptor);
    JComponent editorComponent = editor.createEditorComponent(propertyDescriptor, bindingContext);
    editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight));
    editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight));

    preProcessingPanel.add(createCheckboxComponent("preprocessTool", editorComponent, newOperatorDescriptor.getPreprocessTool()));
    preProcessingPanel.add(new JLabel(Bundle.CTL_Label_PreprocessingTool_Text()));
    preProcessingPanel.add(editorComponent);

    propertyDescriptor = propertyContainer.getDescriptor("processingWriter");
    editor = PropertyEditorRegistry.getInstance().findPropertyEditor(propertyDescriptor);
    editorComponent = editor.createEditorComponent(propertyDescriptor, bindingContext);
    editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight));
    editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight));

    JComponent writeComponent = createCheckboxComponent("writeForProcessing", editorComponent, newOperatorDescriptor.shouldWriteBeforeProcessing());

    preProcessingPanel.add(writeComponent);
    preProcessingPanel.add(new JLabel(Bundle.CTL_Label_WriteBefore_Text()));
    preProcessingPanel.add(editorComponent);

    TitledBorder title = BorderFactory.createTitledBorder(Bundle.CTL_Panel_PreProcessing_Border_TitleText());
    preProcessingPanel.setBorder(title);

    SpringUtilities.makeCompactGrid(preProcessingPanel, 2, 3, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING);

    return preProcessingPanel;
}
 
Example 7
Source File: NewProjectWizard.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected WizardDescriptor.Panel<WizardDescriptor> createTemplateChooser() {
    WizardDescriptor.Panel<WizardDescriptor> panel = new ProjectTemplatePanel();
    JComponent jc = (JComponent)panel.getComponent ();
    jc.setPreferredSize( new java.awt.Dimension (500, 340) );
    jc.setName (NbBundle.getBundle (NewProjectWizard.class).getString ("LBL_NewProjectWizard_Name")); // NOI18N
    jc.getAccessibleContext ().setAccessibleName (NbBundle.getBundle (NewProjectWizard.class).getString ("ACSN_NewProjectWizard")); // NOI18N
    jc.getAccessibleContext ().setAccessibleDescription (NbBundle.getBundle (NewProjectWizard.class).getString ("ACSD_NewProjectWizard")); // NOI18N
    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer (0));
    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_DATA, new String[] {
            NbBundle.getBundle (NewProjectWizard.class).getString ("LBL_NewProjectWizard_Name"), // NOI18N
            NbBundle.getBundle (NewProjectWizard.class).getString ("LBL_NewProjectWizard_Dots")}); // NOI18N
            
    return panel;
}
 
Example 8
Source File: OnePageWindow.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Add a component for the Text.
 * 
 * @param panel Container.
 * @param constraints Constraints.
 * @param textPane Text pane.
 * @param undo Button undo.
 */
protected void addTextContents(
    JPanel panel, GridBagConstraints constraints,
    MWPane textPane, JButton undo) {
  if (textPane != null) {
    Configuration config = Configuration.getConfiguration();
    textPane.setBackground(Color.WHITE);
    textPane.setEditable(true);
    if (undo != null) {
      textPane.getUndoManager().setUndoLevels(config.getInt(
          null,
          ConfigurationValueInteger.ANALYSIS_UNDO_LVL));
    }
    textPane.addPropertyChangeListener(
        MWPane.PROPERTY_MODIFIED,
        new PropertyChangeListener() {

          /* (non-Javadoc)
           * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
           */
          @Override
          public void propertyChange(@SuppressWarnings("unused") PropertyChangeEvent evt) {
            updateComponentState();
          }
          
        });
    JComponent scrollContents = MWPane.createComplexPane(textPane);
    scrollContents.setMinimumSize(new Dimension(100, 100));
    scrollContents.setPreferredSize(new Dimension(1000, 500));
    panel.add(scrollContents, constraints);
  }
}
 
Example 9
Source File: ImporterWizardPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void initPanel(JComponent comp, int wizardNumber) {
    comp.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, Boolean.TRUE); // NOI18N
    comp.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, Boolean.TRUE); // NOI18N
    comp.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, Boolean.TRUE); // NOI18N
    comp.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX,  // NOI18N
            new Integer(wizardNumber));
    comp.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, new String[] { // NOI18N
        WORKSPACE_LOCATION_STEP, PROJECTS_SELECTION_STEP
    });
    comp.setPreferredSize(new java.awt.Dimension(500, 380));
}
 
Example 10
Source File: CompletionLayoutPopup.java    From netbeans with Apache License 2.0 5 votes vote down vote up
final void resetPreferredSize() {
    JComponent comp = getContentComponent();
    if (comp == null){
        return;
    }
    comp.setPreferredSize(null);
}
 
Example 11
Source File: ErrorDlg.java    From swift-explorer with Apache License 2.0 5 votes vote down vote up
private JComponent setPrefSize (JComponent comp, int minPrefW, int minPrefH)
{
	if (comp == null)
		return null ;
	comp.setMinimumSize(new Dimension(200, 150));
	comp.setPreferredSize(new Dimension(minPrefW, minPrefH));
	comp.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
	return comp ;
}
 
Example 12
Source File: XDMScrollBarUI.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void installUI(JComponent c) {
	super.installUI(c);

	darkMode = scrollbar instanceof DarkScrollBar;
	if ((scrollbar.getOrientation() == JScrollBar.HORIZONTAL)) {
		c.setPreferredSize(new Dimension(XDMUtils.getScaledInt(15),
				darkMode ? XDMUtils.getScaledInt(8) : XDMUtils.getScaledInt(15)));
	} else {
		c.setPreferredSize(new Dimension(darkMode ? XDMUtils.getScaledInt(8) : XDMUtils.getScaledInt(15),
				XDMUtils.getScaledInt(15)));
	}
}
 
Example 13
Source File: ToolAdapterEditorDialog.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected JPanel createToolInfoPanel() {
    JPanel container = new JPanel(new SpringLayout());

    JPanel configPanel = new JPanel(new SpringLayout());
    configPanel.setBorder(BorderFactory.createTitledBorder(Bundle.CTL_Panel_ConfigParams_Text()));

    JPanel panelToolFiles = new JPanel(new SpringLayout());

    PropertyDescriptor propertyDescriptor = propertyContainer.getDescriptor(ToolAdapterConstants.MAIN_TOOL_FILE_LOCATION);
    propertyDescriptor.setValidator(new NotEmptyValidator());
    PropertyEditor editor = PropertyEditorRegistry.getInstance().findPropertyEditor(propertyDescriptor);
    JComponent editorComponent = editor.createEditorComponent(propertyDescriptor, bindingContext);
    editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight));
    editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight));

    panelToolFiles.add(new JLabel(Bundle.CTL_Label_ToolLocation_Text()));
    panelToolFiles.add(editorComponent);

    propertyDescriptor = propertyContainer.getDescriptor(ToolAdapterConstants.WORKING_DIR);
    propertyDescriptor.setAttribute("directory", true);
    propertyDescriptor.setValidator((property, value) -> {
        if (value == null || value.toString().trim().isEmpty()) {
            throw new ValidationException(MessageFormat.format("Value for ''{0}'' must not be empty.",
                    property.getDescriptor().getDisplayName()));
        }
    });
    editor = PropertyEditorRegistry.getInstance().findPropertyEditor(propertyDescriptor);
    editorComponent = editor.createEditorComponent(propertyDescriptor, bindingContext);
    editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight));
    editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight));

    panelToolFiles.add(new JLabel(Bundle.CTL_Label_WorkDir_Text()));
    panelToolFiles.add(editorComponent);

    SpringUtilities.makeCompactGrid(panelToolFiles, 2, 2, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING);

    configPanel.add(panelToolFiles);

    JPanel checkPanel = new JPanel(new SpringLayout());

    propertyDescriptor = propertyContainer.getDescriptor(ToolAdapterConstants.HANDLE_OUTPUT);
    editor = PropertyEditorRegistry.getInstance().findPropertyEditor(propertyDescriptor);
    editorComponent = editor.createEditorComponent(propertyDescriptor, bindingContext);
    editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight));
    editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight));

    checkPanel.add(editorComponent);
    checkPanel.add(new JLabel("Tool produces the name of the output product"));

    SpringUtilities.makeCompactGrid(checkPanel, 1, 2, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING);

    configPanel.add(checkPanel);

    JLabel label = new JLabel(Bundle.CTL_Label_CmdLineTemplate_Text());
    configPanel.add(label);

    JScrollPane scrollPane = new JScrollPane(createTemplateEditorField());
    configPanel.add(scrollPane);

    SpringUtilities.makeCompactGrid(configPanel, 4, 1, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING);

    container.add(configPanel);
    container.add(createPatternsPanel());
    SpringUtilities.makeCompactGrid(container, 2, 1, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING);

    return container;
}
 
Example 14
Source File: PreviewHintFix.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public ChangeInfo implement() throws Exception {
    EditList edits = fix.getEditList();

    Document oldDoc = info.getSnapshot().getSource().getDocument(true);
    //OffsetRange range = edits.getRange();
    OffsetRange range = new OffsetRange(0, oldDoc.getLength());
    String oldSource = oldDoc.getText(range.getStart(), range.getEnd());

    String mimeType = (String) oldDoc.getProperty("mimeType"); //NOI18N
    BaseDocument newDoc = new BaseDocument(false, mimeType);

    Language language = (Language) oldDoc.getProperty(Language.class);
    newDoc.putProperty(Language.class, language);
    newDoc.insertString(0, oldSource, null);
    edits.applyToDocument(newDoc);
    String newSource = newDoc.getText(0, newDoc.getLength());

    String oldTitle = NbBundle.getMessage(PreviewHintFix.class, "CurrentSource");
    String newTitle = NbBundle.getMessage(PreviewHintFix.class, "FixedSource");

    final DiffController diffView = DiffController.create(
            new DiffSource(oldSource, oldTitle),
            new DiffSource(newSource, newTitle));


    JComponent jc = diffView.getJComponent();

    jc.setPreferredSize(new Dimension(800, 600));

    // Warp view to a particular diff?
    // I can't just always jump to difference number 0, because when a hint
    // has changed only the whitespace (such as the fix which moves =begin entries to column 0)
    // there are no diffs, even though I want to jump to the relevant line.
    final int index = 0;
    final int firstLine = diffView.getDifferenceCount() == 0 ? NbDocument.findLineNumber((StyledDocument) oldDoc, edits.getRange().
            getStart()) : -1;
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            if (firstLine != -1) {
                diffView.setLocation(DiffController.DiffPane.Base,
                        DiffController.LocationType.LineNumber, firstLine);
            } else if (diffView.getDifferenceCount() > 0) {
                diffView.setLocation(DiffController.DiffPane.Base,
                        DiffController.LocationType.DifferenceIndex, index);
            }
        }
    });

    JButton apply = new JButton(NbBundle.getMessage(PreviewHintFix.class, "Apply"));
    JButton ok = new JButton(NbBundle.getMessage(PreviewHintFix.class, "Ok"));
    JButton cancel = new JButton(NbBundle.getMessage(PreviewHintFix.class, "Cancel"));
    String dialogTitle = NbBundle.getMessage(PreviewHintFix.class, "PreviewTitle",
            fix.getDescription());

    DialogDescriptor descriptor =
            new DialogDescriptor(jc, dialogTitle, true,
            new Object[]{apply, ok, cancel}, ok, DialogDescriptor.DEFAULT_ALIGN, null, null,
            true);
    Dialog dlg = null;

    try {
        dlg = DialogDisplayer.getDefault().createDialog(descriptor);
        dlg.setVisible(true);
        if (descriptor.getValue() == apply) {
            fix.implement();
        }
    } finally {
        if (dlg != null) {
            dlg.dispose();
        }
    }

    return null;
}
 
Example 15
Source File: CollapsiblePanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public FilesPanel(VCSCommitPanel master, Map<String, VCSCommitFilter> filters, int preferedHeight)  {
    super(master, master.getModifier().getMessage(VCSCommitPanelModifier.BundleMessage.FILE_PANEL_TITLE), DEFAULT_DISPLAY_FILES);
    this.filters = filters;
    
    master.getCommitTable().labelFor(filesLabel);
    
    JComponent table = master.getCommitTable().getComponent();
    
    Mnemonics.setLocalizedText(filesLabel, getMessage("CTL_CommitForm_FilesToCommit"));         // NOI18N
    filesLabel.setMaximumSize(new Dimension(Integer.MAX_VALUE, filesLabel.getMaximumSize().height));
    
    table.setPreferredSize(new Dimension(0, preferedHeight));
    
    ButtonGroup bg = new ButtonGroup();
    toolbar = new JToolBar();
    toolbar.setFloatable(false);
    
    for (VCSCommitFilter filter : filters.values()) {
        
        JToggleButton tgb = new JToggleButton();
        tgb.setIcon(filter.getIcon()); 
        tgb.setToolTipText(filter.getTooltip()); 
        tgb.setFocusable(false);
        tgb.setSelected(filter.isSelected());
        tgb.addActionListener(this);                
        tgb.putClientProperty(TOOLBAR_FILTER, filter);
        bg.add(tgb);
        toolbar.add(tgb);
        
    }
    toolbar.setAlignmentX(LEFT_ALIGNMENT);        
    
    sectionPanel.add(toolbar);
    sectionPanel.add(table);
    sectionPanel.add(VCSCommitPanel.makeVerticalStrut(filesLabel, table, RELATED, sectionPanel));
    sectionPanel.add(filesLabel);
    
    sectionPanel.setAlignmentX(LEFT_ALIGNMENT);
    filesLabel.setAlignmentX(LEFT_ALIGNMENT);
    table.setAlignmentX(LEFT_ALIGNMENT);
}
 
Example 16
Source File: DiffViewAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NbBundle.Messages({
        "LBL_Expected=Expected",
        "LBL_Actual=Actual",
        "LBL_OK=OK",
        "LBL_Diff=Differences"})
@Override
public void actionPerformed(ActionEvent e) {

    StringComparisonSource expected =
            new StringComparisonSource(
            Bundle.LBL_Expected(),
            comparisonFailure.getExpected(),
            comparisonFailure.getMimeType());

    StringComparisonSource actual =
            new StringComparisonSource(
            Bundle.LBL_Actual(),
            comparisonFailure.getActual(),
            comparisonFailure.getMimeType());


    try {
        JComponent diffComponent = DiffController.create(expected, actual).getJComponent();
        diffComponent.setPreferredSize(new Dimension(500, 250));
        JButton ok = new JButton(Bundle.LBL_OK());
        final DialogDescriptor descriptor = new DialogDescriptor(
                diffComponent,
                Bundle.LBL_Diff(),
                true,
                new Object[]{ok},
                ok,
                DialogDescriptor.DEFAULT_ALIGN,
                null,
                null);

        Dialog dialog = null;
        try {
            dialog = DialogDisplayer.getDefault().createDialog(descriptor);
            dialog.setVisible(true);
        } finally {
            if (dialog != null) {
                dialog.dispose();
            }
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }

}
 
Example 17
Source File: SwingHelper.java    From azure-devops-intellij with MIT License 4 votes vote down vote up
public static void setPreferredHeight(final JComponent component, final int height) {
    final Dimension size = component.getPreferredSize();
    size.setSize(size.getWidth(), JBUI.scale(height));
    component.setPreferredSize(size);
}
 
Example 18
Source File: LauncherFrame.java    From usergrid with Apache License 2.0 4 votes vote down vote up
public void setPreferredWidth( JComponent jc, int width ) {
    Dimension max = jc.getPreferredSize();
    max.width = width;
    jc.setPreferredSize( max );
}
 
Example 19
Source File: MainFrame.java    From uima-uimaj with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the preferred size.
 *
 * @param comp the comp
 * @param propPrefix the prop prefix
 */
public void setPreferredSize(JComponent comp, String propPrefix) {
  // assert(comp != null);
  comp.setPreferredSize(getDimension(propPrefix));
}
 
Example 20
Source File: MSwingUtilities.java    From javamelody with Apache License 2.0 2 votes vote down vote up
/**
 * Démarre un composant dans une Frame sans pack() (utile pour écrire des méthodes main sur des panels en développement).
 *
 * @param component
 *           JComponent
 * @return la Frame créée
 */
public static JFrame runUnpacked(final JComponent component) {
	component.setPreferredSize(component.getSize());
	return run(component);
}