下面列出了javax.swing.JComboBox#setMinimumSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
public LanguageSelectionPanel() {
languagesCombo = new JComboBox();
languagesCombo.setMinimumSize(dim);
languagesCombo.setPreferredSize(dim);
for (Country c : LocaleUtil.getCountries()) {
languagesCombo.addItem(c);
}
languagesCombo.setSelectedItem(LocaleUtil.getCountry(Globals.getConfigLocale()));
languagesCombo.setRenderer(new CountryRenderer());
defaultCheck = new JCheckBox(I18NSupport.getString("languages.default"));
setLayout(new GridBagLayout());
add(new JLabel(I18NSupport.getString("languages.selection")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
add(languagesCombo, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(5, 0, 5, 5), 0, 0));
add(defaultCheck, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
}
/**
* Adds a zoom combo box to the toolbar
*
* @param toolBar the JToolBar to add the button to
* @param action the action that the ZoomComboBox performs
* @param view application view
*/
private void addZoomComboBox(JToolBar toolBar, Action action, String[] zoomExamples, PipeApplicationView view) {
Dimension zoomComboBoxDimension = new Dimension(65, 28);
JComboBox<String> zoomComboBox = new JComboBox<>(zoomExamples);
zoomComboBox.setEditable(true);
zoomComboBox.setSelectedItem("100%");
zoomComboBox.setMaximumRowCount(zoomExamples.length);
zoomComboBox.setMaximumSize(zoomComboBoxDimension);
zoomComboBox.setMinimumSize(zoomComboBoxDimension);
zoomComboBox.setPreferredSize(zoomComboBoxDimension);
zoomComboBox.setAction(action);
view.registerZoom(zoomComboBox);
toolBar.add(zoomComboBox);
}
@NbBundle.Messages({
"TXT_NonActiveContent=<No View Available - Refresh Manually>",
"TXT_InspectHierarchyHistory=<empty>",
"TOOLTIP_RefreshContent=Refresh for entity under cursor",
"TOOLTIP_OpenJDoc=Open Javadoc Window",
"TOOLTIP_ViewHierarchyType=Hierachy View Type",
"TOOLTIP_InspectHierarchyHistory=Inspect Hierarchy History"
})
public HierarchyTopComponent() {
history = HistorySupport.getInstnace(this.getClass());
jdocFinder = SelectJavadocTask.create(this);
jdocTask = RP.create(jdocFinder);
explorerManager = new ExplorerManager();
rootChildren = new RootChildren();
filters = new HierarchyFilters();
explorerManager.setRootContext(Nodes.rootNode(rootChildren, filters));
selectedNodes = new InstanceContent();
lookup = new AbstractLookup(selectedNodes);
explorerManager.addPropertyChangeListener(this);
initComponents();
setName(Bundle.CTL_HierarchyTopComponent());
setToolTipText(Bundle.HINT_HierarchyTopComponent());
viewTypeCombo = new JComboBox(new DefaultComboBoxModel(ViewType.values()));
viewTypeCombo.setMinimumSize(new Dimension(MIN_TYPE_WIDTH,COMBO_HEIGHT));
viewTypeCombo.addActionListener(this);
viewTypeCombo.setToolTipText(Bundle.TOOLTIP_ViewHierarchyType());
historyCombo = new JComboBox(HistorySupport.createModel(history, Bundle.TXT_InspectHierarchyHistory()));
historyCombo.setMinimumSize(new Dimension(MIN_HISTORY_WIDTH,COMBO_HEIGHT));
historyCombo.setRenderer(HistorySupport.createRenderer(history));
historyCombo.addActionListener(this);
historyCombo.setEnabled(false);
historyCombo.getModel().addListDataListener(this);
historyCombo.setToolTipText(Bundle.TOOLTIP_InspectHierarchyHistory());
refreshButton = new JButton(ImageUtilities.loadImageIcon(REFRESH_ICON, true));
refreshButton.addActionListener(this);
refreshButton.setToolTipText(Bundle.TOOLTIP_RefreshContent());
jdocButton = new JButton(ImageUtilities.loadImageIcon(JDOC_ICON, true));
jdocButton.addActionListener(this);
jdocButton.setToolTipText(Bundle.TOOLTIP_OpenJDoc());
final Box upperToolBar = new MainToolBar(
constrainedComponent(viewTypeCombo, GridBagConstraints.HORIZONTAL, 1.0, new Insets(0,0,0,0)),
constrainedComponent(historyCombo, GridBagConstraints.HORIZONTAL, 1.5, new Insets(0,3,0,0)),
constrainedComponent(refreshButton, GridBagConstraints.NONE, 0.0, new Insets(0,3,0,0)),
constrainedComponent(jdocButton, GridBagConstraints.NONE, 0.0, new Insets(0,3,0,3)));
add(decorateAsUpperPanel(upperToolBar), BorderLayout.NORTH);
contentView = new JPanel();
contentView.setLayout(new CardLayout());
JPanel nonActiveContent = Utils.updateBackground(new JPanel());
nonActiveContent.setLayout(new BorderLayout());
nonActiveInfo = new JLabel(Bundle.TXT_NonActiveContent());
nonActiveInfo.setEnabled(false);
nonActiveInfo.setHorizontalAlignment(SwingConstants.CENTER);
nonActiveContent.add(nonActiveInfo, BorderLayout.CENTER);
btw = createBeanTreeView();
contentView.add(nonActiveContent, NON_ACTIVE_CONTENT);
contentView.add(btw, ACTIVE_CONTENT);
add(contentView,BorderLayout.CENTER);
lowerToolBar = new TapPanel();
lowerToolBar.setOrientation(TapPanel.DOWN);
final JComponent lowerButtons = filters.getComponent();
lowerButtons.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0));
lowerToolBar.add(lowerButtons);
final boolean expanded = NbPreferences.forModule(HierarchyTopComponent.class).
getBoolean(PROP_LOWER_TOOLBAR_EXPANDED, true); //NOI18N
lowerToolBar.setExpanded(expanded);
lowerToolBar.addPropertyChangeListener(this);
add(Utils.updateBackground(lowerToolBar), BorderLayout.SOUTH);
}
/**
* 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;
}
public KeySelectionPanel(boolean showValueField) {
this.showValueField = showValueField;
keysCombo = new JComboBox();
keysCombo.setEditable(true);
AutoCompleteDecorator.decorate(keysCombo);
keysCombo.setMinimumSize(dim);
keysCombo.setPreferredSize(dim);
if (showValueField) {
keysCombo.setEnabled(false);
}
List<String> keys = NextReportsUtil.getReportKeys();
for (String key : keys) {
keysCombo.addItem(key);
}
valueField = new JTextField();
valueField.setMinimumSize(dim);
valueField.setPreferredSize(dim);
allCheck = new JCheckBox(I18NSupport.getString("languages.keys.selection.key.all"));
setLayout(new GridBagLayout());
add(new JLabel(I18NSupport.getString("languages.keys.selection.key")),
new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
add(keysCombo,
new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
if (showValueField) {
add(new JLabel(I18NSupport.getString("languages.keys.selection.value")),
new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
add(valueField,
new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 5), 0, 0));
} else {
add(allCheck,
new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
}