Java Code Examples for javax.swing.JComboBox#getPreferredSize()
The following examples show how to use
javax.swing.JComboBox#getPreferredSize() .
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: RemoteExecutionDialog.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private static JComboBox<String> buildProductFormatNamesComboBox(Insets defaultListItemMargins, int textFieldPreferredHeight, String[] availableFormatNames) { JComboBox<String> productFormatNameComboBox = new JComboBox<String>(availableFormatNames); Dimension formatNameComboBoxSize = productFormatNameComboBox.getPreferredSize(); formatNameComboBoxSize.height = textFieldPreferredHeight; productFormatNameComboBox.setPreferredSize(formatNameComboBoxSize); productFormatNameComboBox.setMinimumSize(formatNameComboBoxSize); LabelListCellRenderer<String> renderer = new LabelListCellRenderer<String>(defaultListItemMargins) { @Override protected String getItemDisplayText(String value) { return value; } }; productFormatNameComboBox.setMaximumRowCount(5); productFormatNameComboBox.setRenderer(renderer); productFormatNameComboBox.setBackground(new Color(0, 0, 0, 0)); // set the transparent color productFormatNameComboBox.setOpaque(true); return productFormatNameComboBox; }
Example 2
Source File: PageFlowToolbarUtilities.java From netbeans with Apache License 2.0 | 4 votes |
/** * Creates a JComboBox for the user to select the scope type. * @param view * @param pfc * @return */ public JComboBox createScopeComboBox() { JComboBox comboBox = new JComboBox(); comboBox.addItem(getScopeLabel(Scope.SCOPE_FACESCONFIG)); comboBox.addItem(getScopeLabel(Scope.SCOPE_PROJECT)); comboBox.addItem(getScopeLabel(Scope.SCOPE_ALL_FACESCONFIG)); //Set the appropriate size of the combo box so it doesn't take up the whole page. Dimension prefSize = comboBox.getPreferredSize(); comboBox.setMinimumSize(prefSize); comboBox.setMaximumSize(prefSize); comboBox.setSelectedItem(getScopeLabel(currentScope)); comboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { PageFlowView view = getPageFlowView(); if (event.getStateChange() == ItemEvent.SELECTED) { String newScope = (String) event.getItem(); /* Save Locations before switching scope */ view.saveLocations(); LogRecord record = new LogRecord(Level.FINE, "PageFLowEditor Scope Changed To:" + newScope); record.setSourceClassName("PageFlowUtilities.ItemListener"); record.setSourceMethodName("itemStateChanged"); record.setParameters(new Object[]{newScope, new Date()}); LOGGER.log(record); setCurrentScope(getScope(newScope)); //As we are setting the current scope, we should update the controller and update the scene. But what happens with setup? /* We don't want the background process to continue adding pins to the pages */ // view.clearBackgroundPinAddingProcess(); /* You don't want to override the data you just stored */ view.getPageFlowController().setupGraphNoSaveData(); } view.requestMultiViewActive(); } }); comboBox.setToolTipText(TT_SCOPE); scopeBox = comboBox; return comboBox; }
Example 3
Source File: MSMSLibrarySubmissionWindow.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
private void createSubmitParamPanel() { // Main panel which holds all the components in a grid pnSubmitParam = new GridBagPanel(); pnSideMenu.add(pnSubmitParam, BorderLayout.NORTH); int rowCounter = 0; // Create labels and components for each parameter for (Parameter p : paramSubmit.getParameters()) { if (!(p instanceof UserParameter)) continue; UserParameter up = (UserParameter) p; JComponent comp = up.createEditingComponent(); comp.setToolTipText(up.getDescription()); // Set the initial value Object value = up.getValue(); if (value != null) up.setValueToComponent(comp, value); // By calling this we make sure the components will never be resized // smaller than their optimal size comp.setMinimumSize(comp.getPreferredSize()); comp.setToolTipText(up.getDescription()); // add separator if (p.getName().equals(LibrarySubmitParameters.LOCALFILE.getName())) { pnSubmitParam.addSeparator(0, rowCounter, 2); rowCounter++; } JLabel label = new JLabel(p.getName()); pnSubmitParam.add(label, 0, rowCounter); label.setLabelFor(comp); parametersAndComponents.put(p.getName(), comp); JComboBox t = new JComboBox(); int comboh = t.getPreferredSize().height; int comph = comp.getPreferredSize().height; int verticalWeight = comph > 2 * comboh ? 1 : 0; pnSubmitParam.add(comp, 1, rowCounter, 1, 1, 1, verticalWeight, GridBagConstraints.VERTICAL); rowCounter++; } }
Example 4
Source File: MSMSLibrarySubmissionWindow.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
private void createMetaDataPanel() { // Main panel which holds all the components in a grid pnMetaData = new GridBagPanel(); scrollMeta = new JScrollPane(pnMetaData); scrollMeta.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollMeta.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); pnSideMenu.add(scrollMeta, BorderLayout.CENTER); int rowCounter = 0; int vertWeightSum = 0; // Create labels and components for each parameter for (Parameter p : paramMeta.getParameters()) { if (!(p instanceof UserParameter)) continue; UserParameter up = (UserParameter) p; JComponent comp = up.createEditingComponent(); comp.setToolTipText(up.getDescription()); // Set the initial value Object value = up.getValue(); if (value != null) up.setValueToComponent(comp, value); // By calling this we make sure the components will never be resized // smaller than their optimal size comp.setMinimumSize(comp.getPreferredSize()); comp.setToolTipText(up.getDescription()); JLabel label = new JLabel(p.getName()); pnMetaData.add(label, 0, rowCounter); label.setLabelFor(comp); parametersAndComponents.put(p.getName(), comp); JComboBox t = new JComboBox(); int comboh = t.getPreferredSize().height; int comph = comp.getPreferredSize().height; // Multiple selection will be expandable, other components not int verticalWeight = comph > 2 * comboh ? 1 : 0; vertWeightSum += verticalWeight; pnMetaData.add(comp, 1, rowCounter, 1, 1, 1, verticalWeight, GridBagConstraints.VERTICAL); rowCounter++; } }