List of usage examples for javax.swing JComboBox addItem
public void addItem(E item)
From source file:cs.gui.stats.PerformanceStats.java
private JComboBox fillScopeDDL(JComboBox ddlScope) { //ddlScope.addItem("All"); ddlScope.addItem("One Day"); ddlScope.addItem("Ten Days"); ddlScope.addItem("One Month"); ddlScope.addItem("Two Months"); ddlScope.addItem("Four Months"); ddlScope.addItem("Six Months"); ddlScope.addItem("Ten Months"); ddlScope.addItem("One Year"); return ddlScope; }
From source file:net.sf.profiler4j.console.ProjectDialog.java
/** * This method initializes rulesTable//from ww w.ja v a 2 s . co m * * @return javax.swing.JTable */ private JTable getRulesTable() { if (rulesTable == null) { rulesTable = new JTable(); rulesTable.setModel(ruleTableModel); rulesTable.setRowMargin(4); rulesTable.setRowHeight(24); rulesTable.setFont(new Font("Monospaced", Font.PLAIN, 14)); TableColumn c; c = rulesTable.getColumnModel().getColumn(0); c.setMinWidth(300); c = rulesTable.getColumnModel().getColumn(1); c.setMinWidth(80); c.setMaxWidth(80); JComboBox editorCb = new JComboBox(); for (Rule.Action a : Rule.Action.values()) { editorCb.addItem(a); } c.setCellEditor(new DefaultCellEditor(editorCb)); c.setCellRenderer(new DefaultTableCellRenderer() { Font font = new Font("Monospaced", Font.BOLD, 13); @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); Rule.Action r = (Rule.Action) value; setHorizontalAlignment(CENTER); setFont(font); if (r == Rule.Action.ACCEPT) { setBackground(Color.GREEN); } else { setBackground(Color.RED); } if (isSelected) { setForeground(Color.YELLOW); } else { setForeground(Color.BLACK); } return this; } }); } return rulesTable; }
From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectCreate.java
private void refresh(JComboBox<String> jComboBoxClonedFrom) { jComboBoxClonedFrom.removeAllItems(); if (names != null) { jComboBoxClonedFrom.addItem(""); for (String name : names) { jComboBoxClonedFrom.addItem(name); }/*from ww w .j a v a 2 s .co m*/ } ((JTextField) jComboBoxClonedFrom.getEditor().getEditorComponent()).setText(""); }
From source file:org.jax.maanova.madata.gui.ArrayScatterPlotPanel.java
private JComboBox initializeArrayComboBox(int dyeCount) { JComboBox arrayComboBox = new JComboBox(); MicroarrayExperimentDesign design = this.experiment.getDesign(); String[] arrayCol = design.getColumnNamed(MicroarrayExperimentDesign.ARRAY_COL_NAME); if (dyeCount == 1) { for (int i = 0; i < arrayCol.length; i++) { arrayComboBox.addItem(arrayCol[i]); }//ww w. j a v a 2 s . c o m } else { String[] dyeCol = design.getColumnNamed(MicroarrayExperimentDesign.DYE_COL_NAME); if (dyeCol.length != arrayCol.length) { String errorMessage = "Expected the number of design terms to be the same for \"" + MicroarrayExperimentDesign.ARRAY_COL_NAME + "\" and \"" + MicroarrayExperimentDesign.DYE_COL_NAME + "\" but a missmatch was found: " + arrayCol.length + " vs. " + dyeCol.length; LOG.severe(errorMessage); MessageDialogUtilities.error(this, errorMessage, "Design Term Count Missmatch"); } else { for (int i = 0; i < arrayCol.length; i++) { arrayComboBox.addItem(arrayCol[i] + ", " + dyeCol[i]); } } } return arrayComboBox; }
From source file:com.diversityarrays.kdxplore.heatmap.HeatMapPanel.java
private JComponent createCurationControls() { rejectSamplesAction.setEnabled(false); acceptSamplesAction.setEnabled(false); deActivatePlotsAction.setEnabled(false); reActivatePlotsAction.setEnabled(false); // | deactivate // accept suppress | reactivate JPanel panel = new JPanel(); GBH gbh = new GBH(panel, 2, 2, 2, 2); gbh.add(0, 0, 1, 1, GBH.NONE, 1, 1, GBH.WEST, new JButton(acceptSamplesAction)); gbh.add(1, 0, 1, 1, GBH.NONE, 1, 1, GBH.WEST, new JButton(rejectSamplesAction)); // if (! askAboutValueForUnscored) { // // TODO i18n // gbh.add(0,1, 2,1, GBH.HORZ, 1,1, GBH.CENTER, "Unscored samples ignored"); // }// ww w. ja v a 2 s. c o m if (xValueRetriever.isPlotColumn() && yValueRetriever.isPlotRow()) { gbh.add(2, 0, 1, 2, GBH.VERT, 1, 1, GBH.CENTER, new JSeparator(JSeparator.VERTICAL)); gbh.add(3, 0, 1, 1, GBH.NONE, 1, 1, GBH.EAST, new JButton(deActivatePlotsAction)); gbh.add(3, 1, 1, 1, GBH.NONE, 1, 1, GBH.EAST, new JButton(reActivatePlotsAction)); } if (markInfo != null) { JComboBox<String> combo = new JComboBox<>(); combo.addItem(NO_MARK); for (String s : markInfo.plotPointsByMark.keySet()) { combo.addItem(s); } combo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List<Point> points = null; Object item = combo.getSelectedItem(); if (item != null && !NO_MARK.equals(item)) { points = markInfo.plotPointsByMark.get(item); markName = item.toString(); } if (Check.isEmpty(points)) { heatMap.removeDecoratedPoints(markInfoRenderer); } else { heatMap.setDecoratedPoints(markInfoRenderer, points.toArray(new Point[points.size()])); } } }); Box newBox = Box.createHorizontalBox(); newBox.add(new JLabel(markInfo.label)); newBox.add(combo); gbh.add(0, 2, 4, 1, GBH.HORZ, 1, 1, GBH.CENTER, newBox); } return panel; }
From source file:com.intuit.tank.tools.debugger.ActionProducer.java
private static JComboBox getComboBox() { JComboBox cb = new JComboBox(); cb.setEditable(true);// ww w. j ava 2 s .c o m Properties props = new Properties(); File f = new File(DEBUGGER_PROPERTIES); InputStream in = null; try { if (f.exists()) { in = new FileInputStream(f); } if (in == null) { // load default in = ActionProducer.class.getClassLoader().getResourceAsStream(DEBUGGER_PROPERTIES); OutputStream out = new FileOutputStream(f); try { IOUtils.copy(in, out); } catch (Exception e) { LOG.error("Cannot write properties: " + e, e); } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); } in = new FileInputStream(f); } props.load(in); for (Object o : props.keySet()) { String key = (String) o; if (key.startsWith(TS_INSTANCE_START)) { String name = key.substring(TS_INSTANCE_START.length()); String value = props.getProperty(key); cb.addItem(name + " (" + value + ")"); } } } catch (Exception e) { LOG.error("Cannot read properties: " + e, e); } finally { IOUtils.closeQuietly(in); } return cb; }
From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java
private void configVDTagsComboBox(JTable table, int columnIndex) { TableColumnModel columnModel = table.getColumnModel(); TableColumn comboColumn = columnModel.getColumn(columnIndex); JComboBox<String> comboBox = new JComboBox<>(); EnumSet<VideoDataTags> allVDTags = EnumSet.allOf(VideoDataTags.class); for (VideoDataTags videoDataTag : allVDTags) { comboBox.addItem(videoDataTag.toString()); }//from w w w .j av a2 s . com comboColumn.setCellEditor(new DefaultCellEditor(comboBox)); /* * allows clearing a problem when cell editor is interrupted, very deep problem. * Only shows if: (A) combobox selection is interupted, (B) dialog is * closed , and (C) Wizard is entered from the menu in this exact order */ cellEditor = comboColumn.getCellEditor(); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText(ResourceBundleHelper.getMessageString("videoTab.tooltip")); comboColumn.setCellRenderer(renderer); }
From source file:com.google.code.facebook.graph.sna.applet.PluggableRendererDemo.java
/** * @param jp panel to which controls will be added *///from ww w .jav a 2 s. c om @SuppressWarnings("serial") protected void addBottomControls(final JPanel jp) { final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.EAST); control_panel.setLayout(new BorderLayout()); final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices")); final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Edges")); final Box both_panel = Box.createVerticalBox(); control_panel.add(vertex_panel, BorderLayout.NORTH); control_panel.add(edge_panel, BorderLayout.SOUTH); control_panel.add(both_panel, BorderLayout.CENTER); // set up vertex controls v_color = new JCheckBox("seed highlight"); v_color.addActionListener(this); v_stroke = new JCheckBox("stroke highlight on selection"); v_stroke.addActionListener(this); v_labels = new JCheckBox("show voltage values"); v_labels.addActionListener(this); v_shape = new JCheckBox("shape by degree"); v_shape.addActionListener(this); v_size = new JCheckBox("size by voltage"); v_size.addActionListener(this); v_size.setSelected(true); v_aspect = new JCheckBox("stretch by degree ratio"); v_aspect.addActionListener(this); v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(this); vertex_panel.add(v_color); vertex_panel.add(v_stroke); vertex_panel.add(v_labels); vertex_panel.add(v_shape); vertex_panel.add(v_size); vertex_panel.add(v_aspect); vertex_panel.add(v_small); // set up edge controls JPanel gradient_panel = new JPanel(new GridLayout(1, 0)); gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint")); no_gradient = new JRadioButton("Solid color"); no_gradient.addActionListener(this); no_gradient.setSelected(true); // gradient_absolute = new JRadioButton("Absolute gradient"); // gradient_absolute.addActionListener(this); gradient_relative = new JRadioButton("Gradient"); gradient_relative.addActionListener(this); ButtonGroup bg_grad = new ButtonGroup(); bg_grad.add(no_gradient); bg_grad.add(gradient_relative); //bg_grad.add(gradient_absolute); gradient_panel.add(no_gradient); //gradientGrid.add(gradient_absolute); gradient_panel.add(gradient_relative); JPanel shape_panel = new JPanel(new GridLayout(3, 2)); shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape")); e_line = new JRadioButton("line"); e_line.addActionListener(this); e_line.setSelected(true); // e_bent = new JRadioButton("bent line"); // e_bent.addActionListener(this); e_wedge = new JRadioButton("wedge"); e_wedge.addActionListener(this); e_quad = new JRadioButton("quad curve"); e_quad.addActionListener(this); e_cubic = new JRadioButton("cubic curve"); e_cubic.addActionListener(this); e_ortho = new JRadioButton("orthogonal"); e_ortho.addActionListener(this); ButtonGroup bg_shape = new ButtonGroup(); bg_shape.add(e_line); // bg.add(e_bent); bg_shape.add(e_wedge); bg_shape.add(e_quad); bg_shape.add(e_ortho); bg_shape.add(e_cubic); shape_panel.add(e_line); // shape_panel.add(e_bent); shape_panel.add(e_wedge); shape_panel.add(e_quad); shape_panel.add(e_cubic); shape_panel.add(e_ortho); fill_edges = new JCheckBox("fill edge shapes"); fill_edges.setSelected(false); fill_edges.addActionListener(this); shape_panel.add(fill_edges); shape_panel.setOpaque(true); e_color = new JCheckBox("highlight edge weights"); e_color.addActionListener(this); e_labels = new JCheckBox("show edge weight values"); e_labels.addActionListener(this); e_uarrow_pred = new JCheckBox("undirected"); e_uarrow_pred.addActionListener(this); e_darrow_pred = new JCheckBox("directed"); e_darrow_pred.addActionListener(this); e_darrow_pred.setSelected(true); e_arrow_centered = new JCheckBox("centered"); e_arrow_centered.addActionListener(this); JPanel arrow_panel = new JPanel(new GridLayout(1, 0)); arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows")); arrow_panel.add(e_uarrow_pred); arrow_panel.add(e_darrow_pred); arrow_panel.add(e_arrow_centered); e_show_d = new JCheckBox("directed"); e_show_d.addActionListener(this); e_show_d.setSelected(true); e_show_u = new JCheckBox("undirected"); e_show_u.addActionListener(this); e_show_u.setSelected(true); JPanel show_edge_panel = new JPanel(new GridLayout(1, 0)); show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges")); show_edge_panel.add(e_show_u); show_edge_panel.add(e_show_d); shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(shape_panel); gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(gradient_panel); show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(show_edge_panel); arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(arrow_panel); e_color.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_color); e_labels.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_labels); // set up zoom controls zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>"); zoom_at_mouse.addActionListener(this); zoom_at_mouse.setSelected(true); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JPanel zoomPanel = new JPanel(); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); plus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(plus); minus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(minus); zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(zoom_at_mouse); JPanel fontPanel = new JPanel(); // add font and zoom controls to center panel font = new JCheckBox("bold text"); font.addActionListener(this); font.setAlignmentX(Component.CENTER_ALIGNMENT); fontPanel.add(font); both_panel.add(zoomPanel); both_panel.add(fontPanel); JComboBox modeBox = gm.getModeComboBox(); modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel modePanel = new JPanel(new BorderLayout()) { public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel comboGrid = new JPanel(new GridLayout(0, 1)); comboGrid.add(modePanel); fontPanel.add(comboGrid); JComboBox cb = new JComboBox(); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.NE); cb.addItem(Renderer.VertexLabel.Position.E); cb.addItem(Renderer.VertexLabel.Position.SE); cb.addItem(Renderer.VertexLabel.Position.S); cb.addItem(Renderer.VertexLabel.Position.SW); cb.addItem(Renderer.VertexLabel.Position.W); cb.addItem(Renderer.VertexLabel.Position.NW); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.CNTR); cb.addItem(Renderer.VertexLabel.Position.AUTO); cb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem(); vv.getRenderer().getVertexLabelRenderer().setPosition(position); vv.repaint(); } }); cb.setSelectedItem(Renderer.VertexLabel.Position.SE); JPanel positionPanel = new JPanel(); positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position")); positionPanel.add(cb); comboGrid.add(positionPanel); }
From source file:edu.uci.ics.jung.samples.PluggableRendererDemo.java
/** * @param jp panel to which controls will be added *//* w ww. ja v a 2s .c om*/ @SuppressWarnings({ "rawtypes", "unchecked" }) protected void addBottomControls(final JPanel jp) { final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.EAST); control_panel.setLayout(new BorderLayout()); final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices")); final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Edges")); final Box both_panel = Box.createVerticalBox(); control_panel.add(vertex_panel, BorderLayout.NORTH); control_panel.add(edge_panel, BorderLayout.SOUTH); control_panel.add(both_panel, BorderLayout.CENTER); // set up vertex controls v_color = new JCheckBox("seed highlight"); v_color.addActionListener(this); v_stroke = new JCheckBox("stroke highlight on selection"); v_stroke.addActionListener(this); v_labels = new JCheckBox("show voltage values"); v_labels.addActionListener(this); v_shape = new JCheckBox("shape by degree"); v_shape.addActionListener(this); v_size = new JCheckBox("size by voltage"); v_size.addActionListener(this); v_size.setSelected(true); v_aspect = new JCheckBox("stretch by degree ratio"); v_aspect.addActionListener(this); v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(this); vertex_panel.add(v_color); vertex_panel.add(v_stroke); vertex_panel.add(v_labels); vertex_panel.add(v_shape); vertex_panel.add(v_size); vertex_panel.add(v_aspect); vertex_panel.add(v_small); // set up edge controls JPanel gradient_panel = new JPanel(new GridLayout(1, 0)); gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint")); no_gradient = new JRadioButton("Solid color"); no_gradient.addActionListener(this); no_gradient.setSelected(true); // gradient_absolute = new JRadioButton("Absolute gradient"); // gradient_absolute.addActionListener(this); gradient_relative = new JRadioButton("Gradient"); gradient_relative.addActionListener(this); ButtonGroup bg_grad = new ButtonGroup(); bg_grad.add(no_gradient); bg_grad.add(gradient_relative); //bg_grad.add(gradient_absolute); gradient_panel.add(no_gradient); //gradientGrid.add(gradient_absolute); gradient_panel.add(gradient_relative); JPanel shape_panel = new JPanel(new GridLayout(3, 2)); shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape")); e_line = new JRadioButton("line"); e_line.addActionListener(this); e_line.setSelected(true); // e_bent = new JRadioButton("bent line"); // e_bent.addActionListener(this); e_wedge = new JRadioButton("wedge"); e_wedge.addActionListener(this); e_quad = new JRadioButton("quad curve"); e_quad.addActionListener(this); e_cubic = new JRadioButton("cubic curve"); e_cubic.addActionListener(this); e_ortho = new JRadioButton("orthogonal"); e_ortho.addActionListener(this); ButtonGroup bg_shape = new ButtonGroup(); bg_shape.add(e_line); // bg.add(e_bent); bg_shape.add(e_wedge); bg_shape.add(e_quad); bg_shape.add(e_ortho); bg_shape.add(e_cubic); shape_panel.add(e_line); // shape_panel.add(e_bent); shape_panel.add(e_wedge); shape_panel.add(e_quad); shape_panel.add(e_cubic); shape_panel.add(e_ortho); fill_edges = new JCheckBox("fill edge shapes"); fill_edges.setSelected(false); fill_edges.addActionListener(this); shape_panel.add(fill_edges); shape_panel.setOpaque(true); e_color = new JCheckBox("highlight edge weights"); e_color.addActionListener(this); e_labels = new JCheckBox("show edge weight values"); e_labels.addActionListener(this); e_uarrow_pred = new JCheckBox("undirected"); e_uarrow_pred.addActionListener(this); e_darrow_pred = new JCheckBox("directed"); e_darrow_pred.addActionListener(this); e_darrow_pred.setSelected(true); e_arrow_centered = new JCheckBox("centered"); e_arrow_centered.addActionListener(this); JPanel arrow_panel = new JPanel(new GridLayout(1, 0)); arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows")); arrow_panel.add(e_uarrow_pred); arrow_panel.add(e_darrow_pred); arrow_panel.add(e_arrow_centered); e_show_d = new JCheckBox("directed"); e_show_d.addActionListener(this); e_show_d.setSelected(true); e_show_u = new JCheckBox("undirected"); e_show_u.addActionListener(this); e_show_u.setSelected(true); JPanel show_edge_panel = new JPanel(new GridLayout(1, 0)); show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges")); show_edge_panel.add(e_show_u); show_edge_panel.add(e_show_d); shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(shape_panel); gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(gradient_panel); show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(show_edge_panel); arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(arrow_panel); e_color.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_color); e_labels.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_labels); // set up zoom controls zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>"); zoom_at_mouse.addActionListener(this); zoom_at_mouse.setSelected(true); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JPanel zoomPanel = new JPanel(); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); plus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(plus); minus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(minus); zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(zoom_at_mouse); JPanel fontPanel = new JPanel(); // add font and zoom controls to center panel font = new JCheckBox("bold text"); font.addActionListener(this); font.setAlignmentX(Component.CENTER_ALIGNMENT); fontPanel.add(font); both_panel.add(zoomPanel); both_panel.add(fontPanel); JComboBox modeBox = gm.getModeComboBox(); modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel modePanel = new JPanel(new BorderLayout()) { public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel comboGrid = new JPanel(new GridLayout(0, 1)); comboGrid.add(modePanel); fontPanel.add(comboGrid); JComboBox cb = new JComboBox(); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.NE); cb.addItem(Renderer.VertexLabel.Position.E); cb.addItem(Renderer.VertexLabel.Position.SE); cb.addItem(Renderer.VertexLabel.Position.S); cb.addItem(Renderer.VertexLabel.Position.SW); cb.addItem(Renderer.VertexLabel.Position.W); cb.addItem(Renderer.VertexLabel.Position.NW); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.CNTR); cb.addItem(Renderer.VertexLabel.Position.AUTO); cb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem(); vv.getRenderer().getVertexLabelRenderer().setPosition(position); vv.repaint(); } }); cb.setSelectedItem(Renderer.VertexLabel.Position.SE); JPanel positionPanel = new JPanel(); positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position")); positionPanel.add(cb); comboGrid.add(positionPanel); }
From source file:net.itransformers.topologyviewer.gui.GraphViewerPanel.java
private JComboBox createHopsCombo() { HopsType hopsType = viewerConfig.getHops(); JComboBox hopsCombo = new JComboBox(); if (hopsType == null) return hopsCombo; String[] hopsArr = hopsType.getValue().split(","); for (String hops : hopsArr) { final int hopsInt = Integer.parseInt(hops); hopsCombo.addItem(hopsInt); }/*from w ww . j a v a2 s.co m*/ hopsCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Integer hops = (Integer) ((JComboBox) e.getSource()).getSelectedItem(); currentHops = hops; } }); currentHops = Integer.valueOf(hopsType.getSelected()); hopsCombo.setSelectedItem(currentHops); return hopsCombo; }