List of usage examples for javax.swing JComboBox addItem
public void addItem(E item)
From source file:TableRenderDemo.java
public void setUpSportColumn(JTable table, TableColumn sportColumn) { // Set up the editor for the sport cells. JComboBox comboBox = new JComboBox(); comboBox.addItem("Snowboarding"); comboBox.addItem("Rowing"); comboBox.addItem("Knitting"); comboBox.addItem("Speed reading"); comboBox.addItem("Pool"); comboBox.addItem("None of the above"); sportColumn.setCellEditor(new DefaultCellEditor(comboBox)); // Set up tool tips for the sport cells. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); sportColumn.setCellRenderer(renderer); }
From source file:components.TableRenderDemo.java
public void setUpSportColumn(JTable table, TableColumn sportColumn) { //Set up the editor for the sport cells. JComboBox comboBox = new JComboBox(); comboBox.addItem("Snowboarding"); comboBox.addItem("Rowing"); comboBox.addItem("Knitting"); comboBox.addItem("Speed reading"); comboBox.addItem("Pool"); comboBox.addItem("None of the above"); sportColumn.setCellEditor(new DefaultCellEditor(comboBox)); //Set up tool tips for the sport cells. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); sportColumn.setCellRenderer(renderer); }
From source file:TableCellRenderTest.java
public TableCellRenderFrame() { setTitle("TableCellRenderTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); TableModel model = new PlanetTableModel(); JTable table = new JTable(model); table.setRowSelectionAllowed(false); // set up renderers and editors table.setDefaultRenderer(Color.class, new ColorTableCellRenderer()); table.setDefaultEditor(Color.class, new ColorTableCellEditor()); JComboBox moonCombo = new JComboBox(); for (int i = 0; i <= 20; i++) moonCombo.addItem(i); TableColumnModel columnModel = table.getColumnModel(); TableColumn moonColumn = columnModel.getColumn(PlanetTableModel.MOONS_COLUMN); moonColumn.setCellEditor(new DefaultCellEditor(moonCombo)); moonColumn.setHeaderRenderer(table.getDefaultRenderer(ImageIcon.class)); moonColumn.setHeaderValue(new ImageIcon("Moons.gif")); // show table table.setRowHeight(100);//from w w w . j av a2 s. c o m add(new JScrollPane(table), BorderLayout.CENTER); }
From source file:org.jfree.demo.DrawStringDemo.java
/** * Populates a combo box with the available {@link TextAnchor} options. * * @param combo the combo box.//from w ww.ja va 2 s .co m */ private void populateTextAnchorCombo(final JComboBox combo) { combo.addItem("TextAnchor.TOP_LEFT"); combo.addItem("TextAnchor.TOP_CENTER"); combo.addItem("TextAnchor.TOP_RIGHT"); combo.addItem("TextAnchor.HALF_ASCENT_LEFT"); combo.addItem("TextAnchor.HALF_ASCENT_CENTER"); combo.addItem("TextAnchor.HALF_ASCENT_RIGHT"); combo.addItem("TextAnchor.CENTER_LEFT"); combo.addItem("TextAnchor.CENTER"); combo.addItem("TextAnchor.CENTER_RIGHT"); combo.addItem("TextAnchor.BASELINE_LEFT"); combo.addItem("TextAnchor.BASELINE_CENTER"); combo.addItem("TextAnchor.BASELINE_RIGHT"); combo.addItem("TextAnchor.BOTTOM_LEFT"); combo.addItem("TextAnchor.BOTTOM_CENTER"); combo.addItem("TextAnchor.BOTTOM_RIGHT"); }
From source file:ShapeTest.java
public ShapeTestFrame() { setTitle("ShapeTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); final ShapeComponent comp = new ShapeComponent(); add(comp, BorderLayout.CENTER); final JComboBox comboBox = new JComboBox(); comboBox.addItem(new LineMaker()); comboBox.addItem(new RectangleMaker()); comboBox.addItem(new RoundRectangleMaker()); comboBox.addItem(new EllipseMaker()); comboBox.addItem(new ArcMaker()); comboBox.addItem(new PolygonMaker()); comboBox.addItem(new QuadCurveMaker()); comboBox.addItem(new CubicCurveMaker()); comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { ShapeMaker shapeMaker = (ShapeMaker) comboBox.getSelectedItem(); comp.setShapeMaker(shapeMaker); }/*from www.j av a2 s . co m*/ }); add(comboBox, BorderLayout.NORTH); comp.setShapeMaker((ShapeMaker) comboBox.getItemAt(0)); }
From source file:logdruid.ui.table.StatRecordingEditorTable.java
public void setUpTypeColumn(JTable theTable, TableColumn TypeColumn) { // Set up the editor for the Type cells. JComboBox comboBox = new JComboBox(); comboBox.addItem("word"); comboBox.addItem("string"); comboBox.addItem("long"); comboBox.addItem("double"); comboBox.addItem("date"); comboBox.addItem("percent"); TypeColumn.setCellEditor(new DefaultCellEditor(comboBox)); // Set up tool tips for the Type cells. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); TypeColumn.setCellRenderer(renderer); }
From source file:logdruid.ui.table.EventRecordingEditorTable.java
public void setUpTypeColumn(JTable theTable, TableColumn typeColumn) { // Set up the editor for the type cells. JComboBox comboBox = new JComboBox(); comboBox.addItem("word"); comboBox.addItem("string"); comboBox.addItem("long"); comboBox.addItem("double"); comboBox.addItem("date"); comboBox.addItem("percent"); typeColumn.setCellEditor(new DefaultCellEditor(comboBox)); // Set up tool tips for the type cells. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); typeColumn.setCellRenderer(renderer); }
From source file:logdruid.ui.table.EventRecordingEditorTable.java
public void setUpProcessingColumn(JTable theTable, TableColumn typeColumn) { JComboBox functionComboBox = new JComboBox(); functionComboBox.addItem("capture"); functionComboBox.addItem("duration"); functionComboBox.addItem("occurrences"); functionComboBox.addItem("sum"); typeColumn.setCellEditor(new DefaultCellEditor(functionComboBox)); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for combo box"); typeColumn.setCellRenderer(renderer); }
From source file:com.floreantpos.bo.ui.explorer.ModifierExplorer.java
private JPanel buildSearchForm() { List<MenuModifierGroup> grpName; JPanel panel = new JPanel(); panel.setLayout(new MigLayout("", "[][]30[][]30[]", "[]20[]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ JLabel nameLabel = new JLabel(Messages.getString("ModifierExplorer.3")); //$NON-NLS-1$ JLabel groupLabel = new JLabel(Messages.getString("ModifierExplorer.4")); //$NON-NLS-1$ final JTextField nameField = new JTextField(15); grpName = MenuModifierGroupDAO.getInstance().findAll(); final JComboBox cbGroup = new JComboBox(); cbGroup.addItem(Messages.getString("ModifierExplorer.5")); //$NON-NLS-1$ for (MenuModifierGroup s : grpName) { cbGroup.addItem(s);//from w w w.j av a2 s . c o m } JButton searchBttn = new JButton(Messages.getString("ModifierExplorer.6")); //$NON-NLS-1$ panel.add(nameLabel, "align label"); //$NON-NLS-1$ panel.add(nameField); panel.add(groupLabel); panel.add(cbGroup); panel.add(searchBttn); TitledBorder title; Border loweredetched; loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); title = BorderFactory.createTitledBorder(loweredetched, Messages.getString("ModifierExplorer.8")); //$NON-NLS-1$ title.setTitleJustification(TitledBorder.LEFT); panel.setBorder(title); searchBttn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { List<MenuModifier> modifierList; String txName = nameField.getText(); Object selectedItem = cbGroup.getSelectedItem(); if (selectedItem instanceof MenuModifierGroup) { modifierList = ModifierDAO.getInstance().findModifier(txName, (MenuModifierGroup) selectedItem); } else { modifierList = ModifierDAO.getInstance().findModifier(txName, null); } setModifierList(modifierList); } }); return panel; }
From source file:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java
public SimpleChart(final String title, final StreamConnection connection) { super(title); dataset = new DynamicTimeSeriesCollection(SERIES, COUNT, new Second()); dataset.setTimeBase(new Second(0, 0, 0, 1, 1, Calendar.getInstance().get(Calendar.YEAR))); // Init./*from w w w . ja v a2 s . co m*/ // for (int i = 0; i < SERIES; i++){ // dataset.addSeries(new float[]{0}, i, "Serie " + (i+1)); // } dataset.addSeries(new float[] { 0, 0, 0 }, 0, "Raw"); dataset.addSeries(new float[] { 0, 0, 0 }, 1, "Software"); dataset.addSeries(new float[] { 0, 0, 0 }, 2, "Hardware"); this.connection = connection; // connection.setStreamReader(new FixedStreamReader(1)); JFreeChart chart = createChart(dataset); final JButton run = new JButton(START); run.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); JButton source = (JButton) e.getSource(); try { if (cmd.equals(START)) { connection.addListener(SimpleChart.this); if (!connection.isConnected()) connection.connect(); source.setText(STOP); source.setActionCommand(STOP); } else { connection.removeListener(SimpleChart.this); source.setText(START); source.setActionCommand(START); } } catch (ConnectionException e1) { e1.printStackTrace(); } } }); final JComboBox combo = new JComboBox(); if (connection instanceof UsbConnection) { Collection<String> portNames = UsbConnection.listAvailablePortNames(); for (String name : portNames) { combo.addItem(name); } } combo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object selectedItem = combo.getSelectedItem(); } }); this.add(new ChartPanel(chart), BorderLayout.CENTER); JPanel btnPanel = new JPanel(new FlowLayout()); btnPanel.add(run); btnPanel.add(combo); this.add(btnPanel, BorderLayout.SOUTH); }