public void showDialog () { int selectedIndex = -1; DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i = 0; i < options.length; i++) { model.addElement(options[i][0]); if (getValue(i).equals(currentValue)) selectedIndex = i; } JComboBox comboBox = new JComboBox(model); comboBox.setSelectedIndex(selectedIndex); if (showValueDialog(comboBox, description)) value = getValue(comboBox.getSelectedIndex()); }
reloadFileButton.setText("Reload File"); final JComboBox<ParseMode> modesCombobox = new JComboBox<>(ParseMode.values()); modesCombobox.setSelectedIndex(0); modesCombobox.addActionListener(event -> { model.setParseMode((ParseMode) modesCombobox.getSelectedItem()); reloadAction.actionPerformed(null); }); final JLabel modesLabel = new JLabel("Modes:", SwingConstants.RIGHT); final int leftIndentation = 10; modesLabel.setBorder(BorderFactory.createEmptyBorder(0, leftIndentation, 0, 0)); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(1, 2)); buttonPanel.add(openFileButton); buttonPanel.add(reloadFileButton); final JPanel modesPanel = new JPanel(); modesPanel.add(modesLabel); modesPanel.add(modesCombobox); final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.add(buttonPanel);
private JPanel createLinePane() { JPanel lineStylePane = new JPanel(); lineStylePane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); lineStylePane.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), JMeterUtils.getResString("graph_resp_time_settings_line"))); // $NON-NLS-1$ lineStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("graph_resp_time_stroke_width"), //$NON-NLS-1$ strokeWidthList)); strokeWidthList.setSelectedItem(StatGraphProperties.getStrokeWidth()[DEFAULT_STROKE_WIDTH_LIST]); lineStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("graph_resp_time_shape_label"), //$NON-NLS-1$ pointShapeLine)); pointShapeLine.setSelectedIndex(DEFAULT_LINE_SHAPE_POINT); return lineStylePane; }
private Box setupAlgorithm() { String[] algorithms = {"JCE-symmetry"}; JLabel algoLabel = new JLabel("Symmetry algorithm: "); JComboBox algorithmList = new JComboBox(algorithms); algorithmList.setSelectedIndex(0); Action paramAction = new AbstractAction("Parameters") { public static final long serialVersionUID = 0l; // This method is called when the button is pressed @Override public void actionPerformed(ActionEvent evt) { // Perform action... configureParameters(); } }; JButton parameterButton = new JButton(paramAction); Box hBoxAlgo = Box.createHorizontalBox(); hBoxAlgo.add(Box.createGlue()); hBoxAlgo.add(algoLabel); hBoxAlgo.add(algorithmList); hBoxAlgo.add(Box.createGlue()); hBoxAlgo.add(parameterButton); hBoxAlgo.add(Box.createGlue()); return hBoxAlgo; }
JComboBox comboBox = new JComboBox(...); comboBox.setSelectedIndex(-1); // remove automatic selection of first item comboBox.addActionListener(...); comboBox.setSelectedIndex(0);
public void createGUI(){ setSize(1200, 1000); topPanel = new JPanel(); JComboBox searchType = new JComboBox(new Object[]{"1", "2"}); JComboBox startVertex = new JComboBox(new Object[]{"1", "2"}); JComboBox goalVertex = new JComboBox(new Object[]{"1", "2"}); searchType.setSelectedIndex(1); startVertex.setSelectedIndex(1); startVertex.setActionCommand("start"); goalVertex.setSelectedIndex(1); goalVertex.setActionCommand("goal"); topPanel.add(searchType); topPanel.add(startVertex); topPanel.add(goalVertex); this.setLayout(new BorderLayout()); this.add(topPanel, BorderLayout.NORTH); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); }
enum SomeEnum{ One, Two, Three; } public static void main(String[] args){ JFrame frame = new JFrame(); JComboBox prePopulatedComboBox = new JComboBox(SomeEnum.values()); prePopulatedComboBox.setSelectedIndex(-1); JComboBox postPopulatedComboBox = new JComboBox(); postPopulatedComboBox.setSelectedIndex(-1); for(SomeEnum someEnum : SomeEnum.values()){ postPopulatedComboBox.addItem(someEnum); } //Uncomment the below line to see the difference //postPopulatedComboBox.setSelectedIndex(-1); JPanel panel = new JPanel(new BorderLayout(5,5)); panel.add(prePopulatedComboBox, BorderLayout.NORTH); panel.add(postPopulatedComboBox, BorderLayout.SOUTH); frame.add(panel); frame.setMinimumSize(new Dimension(250,250)); frame.setVisible(true); }
Language l = languageCombo.getItemAt(i); if (l.getLanguageCode().equals(s.getLanguage())) { languageCombo.setSelectedIndex(i); break; add(new JLabel(Localization.getString("settings.language")), "gapleft 56"); add(languageCombo, "grow, wrap"); add(new JLabel(Localization.getString("settings.connectionDriver")), "gapleft 56"); add(connectionDriver, "grow, wrap");
/** * Adds concept accession data sources to drop down box */ private void populateAccessionDataSource() { // accessions are first index by data source DataSource[] dataSources = accessions.keySet().toArray(new DataSource[0]); Arrays.sort(dataSources); // update drop-down box accessionDataSource.removeActionListener(this); accessionDataSource.removeAllItems(); for (DataSource ds : dataSources) { accessionDataSource.addItem(ds); } accessionDataSource.addActionListener(this); accessionDataSource.setSelectedIndex(0); accessionDataSource.revalidate(); }
fontPanel.add(fontScroll, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); fontPanel.add(new JLabel("Size:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); unicodePanel = new JPanel(new GridBagLayout()); GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0)); bitmapPanel.add(new JLabel("Gamma:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); fontPanel.add(new JLabel("Rendering:"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); glyphPageWidthCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] {new Integer(32), new Integer(64), glyphPageWidthCombo.setSelectedIndex(4); glyphPageHeightCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] {new Integer(32), new Integer(64), glyphPageHeightCombo.setSelectedIndex(4); glyphPageCombo = new JComboBox();
private JPanel createGraphTitlePane() { JPanel titleNamePane = new JPanel(new BorderLayout()); syncWithName.setFont(FONT_SMALL); titleNamePane.add(graphTitle, BorderLayout.CENTER); titleNamePane.add(syncWithName, BorderLayout.EAST); JPanel titleStylePane = new JPanel(); titleStylePane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 5)); titleStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_font"), //$NON-NLS-1$ titleFontNameList)); titleFontNameList.setSelectedIndex(DEFAULT_TITLE_FONT_NAME); titleStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_size"), //$NON-NLS-1$ titleFontSizeList)); titleFontSizeList.setSelectedItem(StatGraphProperties.getFontSize()[DEFAULT_TITLE_FONT_SIZE]); titleStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_style"), //$NON-NLS-1$ titleFontStyleList)); titleFontStyleList.setSelectedIndex(DEFAULT_TITLE_FONT_STYLE); JPanel titlePane = new JPanel(new BorderLayout()); titlePane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils.getResString("aggregate_graph_title_group"))); // $NON-NLS-1$ titlePane.add(titleNamePane, BorderLayout.NORTH); titlePane.add(titleStylePane, BorderLayout.SOUTH); return titlePane; }
private void addDockingFrameworkChooser() { String [] frameworks = ServiceManager.getServiceNames(View.DOCKING_FRAMEWORK_PROVIDER_SERVICE); dockingFramework = new JComboBox(frameworks); String framework = View.getDockingFrameworkName(); for (int i = 0; i < frameworks.length; i++) { if (frameworks[i].equals(framework)) { dockingFramework.setSelectedIndex(i); break; } } addComponent(new JLabel(jEdit.getProperty("options.appearance.selectFramework.label")), dockingFramework); }
private Component createTargetChooser() { targetCombo = new JComboBox(new String[] { "1.4", "1.3", "1.2" }); targetCombo.setSelectedIndex(0); targetCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { status.setText(READY); } }); return targetCombo; }
public void showDialog () { int selectedIndex = -1; DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i = 0; i < options.length; i++) { model.addElement(options[i][0]); if (getValue(i).equals(currentValue)) selectedIndex = i; } JComboBox comboBox = new JComboBox(model); comboBox.setSelectedIndex(selectedIndex); if (showValueDialog(comboBox, description)) value = getValue(comboBox.getSelectedIndex()); }
protected JPanel createSourceAddrPanel() { final JPanel sourceAddrPanel = new HorizontalPanel(); sourceAddrPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils .getResString("web_testing_source_ip"))); // $NON-NLS-1$ // Add a new field source ip address (for HC implementations only) sourceIpType.setSelectedIndex(HTTPSamplerBase.SourceType.HOSTNAME.ordinal()); //default: IP/Hostname sourceAddrPanel.add(sourceIpType); sourceIpAddr = new JTextField(); sourceAddrPanel.add(sourceIpAddr); return sourceAddrPanel; }
public void bindToPreferences(JComboBox component, String key, int defaultValue) { try { component.setSelectedIndex(getInt(key, defaultValue)); } catch(IllegalArgumentException e) { e.printStackTrace(); } setInt(key, component.getSelectedIndex()); JComboBoxBindingAction action = new JComboBoxBindingAction(component, key, true); bindings.put(key, action); component.addActionListener(action); }
fontPanel.add(fontScroll, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); fontPanel.add(new JLabel("Size:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); unicodePanel = new JPanel(new GridBagLayout()); GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0)); bitmapPanel.add(new JLabel("Gamma:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); fontPanel.add(new JLabel("Rendering:"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); glyphPageWidthCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] {new Integer(32), new Integer(64), glyphPageWidthCombo.setSelectedIndex(4); glyphPageHeightCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] {new Integer(32), new Integer(64), glyphPageHeightCombo.setSelectedIndex(4); glyphPageCombo = new JComboBox();
private JPanel createGraphTitlePane() { JPanel titleNamePane = new JPanel(new BorderLayout()); syncWithName.setFont(new Font("SansSerif", Font.PLAIN, 10)); titleNamePane.add(graphTitle, BorderLayout.CENTER); titleNamePane.add(syncWithName, BorderLayout.EAST); JPanel titleStylePane = new JPanel(); titleStylePane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 5)); titleStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_font"), //$NON-NLS-1$ titleFontNameList)); titleFontNameList.setSelectedIndex(0); // default: sans serif titleStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_size"), //$NON-NLS-1$ titleFontSizeList)); titleFontSizeList.setSelectedItem(StatGraphProperties.getFontSize()[6]); // default: 16 titleStylePane.add(GuiUtils.createLabelCombo(JMeterUtils.getResString("aggregate_graph_style"), //$NON-NLS-1$ titleFontStyleList)); titleFontStyleList.setSelectedItem(JMeterUtils.getResString("fontstyle.bold")); // $NON-NLS-1$ // default: bold JPanel titlePane = new JPanel(new BorderLayout()); titlePane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils.getResString("aggregate_graph_title_group"))); // $NON-NLS-1$ titlePane.add(titleNamePane, BorderLayout.NORTH); titlePane.add(titleStylePane, BorderLayout.SOUTH); return titlePane; }
private void addFoldStyleChooser() { painters = ServiceManager.getServiceNames(JEditTextArea.FOLD_PAINTER_SERVICE); foldPainter = new JComboBox(); String current = JEditTextArea.getFoldPainterName(); int selected = 0; for (int i = 0; i < painters.length; i++) { String painter = painters[i]; foldPainter.addItem(jEdit.getProperty( "options.gutter.foldStyleNames." + painter, painter)); if (painter.equals(current)) selected = i; } foldPainter.setSelectedIndex(selected); addComponent(new JLabel(jEdit.getProperty("options.gutter.foldStyle.label")), foldPainter); } //}}}