List of usage examples for javax.swing JComboBox JComboBox
public JComboBox()
JComboBox
with a default data model. From source file:Main.java
public Main() { JComboBox jc = new JComboBox(); jc.addItem("France"); jc.addItem("Germany"); jc.addItem("Italy"); jc.addItem("Japan"); jc.addItemListener(this); add(jc);/*from w w w. j a va 2s .c o m*/ jc.firePopupMenuWillBecomeInvisible(); }
From source file:MainClass.java
public MainClass() { JComboBox jc = new JComboBox(); jc.addItem("France"); jc.addItem("Germany"); jc.addItem("Italy"); jc.addItem("Japan"); jc.addItemListener(this); add(jc);//w ww . ja va 2s . co m }
From source file:Main.java
public Main() { JComboBox comboBox = new JComboBox(); comboBox.addItem(new Double(1)); comboBox.addItem(new Double(2.25)); comboBox.addItem(new Double(3.5)); comboBox.setRenderer(new TwoDecimalRenderer(comboBox.getRenderer())); comboBox.setEditable(true);// ww w . j av a 2s .c o m JFrame frame = new JFrame(); frame.add(comboBox, BorderLayout.NORTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public Main() { setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); jComboBox1 = new JComboBox(); jComboBox1.setModel(new DefaultComboBoxModel(new String[] { "1", "2" })); jComboBox1.addItemListener(evt -> { if (jComboBox1.isPopupVisible()) { jComboBox1.setPopupVisible(false); fireTask(evt);/*from www.j a va 2 s . c o m*/ } }); add(jComboBox1); pack(); }
From source file:LabelForComboBox.java
public LabelForComboBox() { JLabel lbl = new JLabel("Color:"); lbl.setDisplayedMnemonic('c'); add(lbl);//from w w w. ja v a 2s . co m add(Box.createHorizontalStrut(20)); JComboBox cbColor = new JComboBox(); cbColor.addItem("red"); cbColor.addItem("blue"); lbl.setLabelFor(cbColor); add(cbColor); }
From source file:Main.java
public TestPane() { setLayout(new GridBagLayout()); update = new JButton("Update"); comboBox = new JComboBox(); update.addActionListener(e -> updateCombo()); updateCombo();/*from w w w.j av a 2 s . c o m*/ add(comboBox); add(update); }
From source file:Main.java
public Main() { setLayout(new FlowLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); table = new Hashtable<Integer, Color>(); table.put(1, Color.RED);//from ww w . j a v a2 s . com table.put(2, Color.BLUE); table.put(3, Color.GREEN); table.put(4, Color.GRAY); c = new JComboBox<String>(); c.addItem("Item 1"); c.addItem("Item 2"); c.addItem("Item 3"); c.addItem("Item 4"); c.addItem("Item 5"); c.addItem("Item 6"); c.addItem("Item 7"); c.addItem("Item 8"); c.setRenderer(new MyListCellRenderer(table)); add(c); setSize(400, 400); setVisible(true); }
From source file:Main.java
public void createUI() { JPanel borderPanel = new JPanel(new BorderLayout()); JLabel northLabel = new JLabel("Nawth"); borderPanel.add(northLabel, BorderLayout.NORTH); JComboBox southCombo = new JComboBox(); borderPanel.add(southCombo, BorderLayout.SOUTH); JPanel centerPanel = new JPanel(); centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.PAGE_AXIS)); JComboBox firstCombo = new JComboBox(); centerPanel.add(firstCombo);/* w ww . j a v a 2 s. c o m*/ centerPanel.add(Box.createVerticalGlue()); JPanel centerPanelConstrain = new JPanel(new GridBagLayout()); centerPanelConstrain.add(centerPanel); borderPanel.add(centerPanelConstrain, BorderLayout.CENTER); getContentPane().add(borderPanel); pack(); }
From source file:FontComboBox.java
public FontComboBox() { setTitle("ComboBoxTest"); setSize(300, 200);//from w w w . j a v a2 s . c o m addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); fontComboBox = new JComboBox(); fontComboBox.setEditable(true); fontComboBox.addItem("Serif"); fontComboBox.addItem("SansSerif"); fontComboBox.addItem("Monospaced"); fontComboBox.addItem("Dialog"); fontComboBox.addItem("DialogInput"); fontComboBox.addActionListener(this); JPanel p = new JPanel(); p.add(fontComboBox); getContentPane().add(p, "North"); getContentPane().add(fontLabel, "Center"); }
From source file:Main.java
public Main() { rOne.addActionListener(new ROneAction()); rTwo.addActionListener(new RTwoAction()); group = new ButtonGroup(); group.add(rOne);/*from w w w. j a v a 2 s . c o m*/ group.add(rTwo); combo = new JComboBox(); combo.addItem("No Values"); combo.addPopupMenuListener(new PopupMenuListener() { public void popupMenuCanceled(PopupMenuEvent evt) { } public void popupMenuWillBecomeInvisible(PopupMenuEvent evt) { jComboBox1PopupMenuWillBecomeInvisible(evt); } public void popupMenuWillBecomeVisible(PopupMenuEvent evt) { } }); label = new JLabel("labelLabel"); this.setLayout(new FlowLayout()); this.add(rOne); this.add(rTwo); this.add(combo); this.add(label); this.pack(); this.setVisible(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }