Java Code Examples for javax.swing.JComboBox#setMinimumSize()

The following examples show how to use javax.swing.JComboBox#setMinimumSize() . 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 vote down vote up
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: LanguageSelectionPanel.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
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));
		
	}
 
Example 3
Source File: PipeApplicationBuilder.java    From PIPE with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example 4
Source File: HierarchyTopComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example 5
Source File: PageFlowToolbarUtilities.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
     * 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 6
Source File: KeySelectionPanel.java    From nextreports-designer with Apache License 2.0 4 votes vote down vote up
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));
    }
}