Package javax.swing

Examples of javax.swing.JComboBox.addItem()


    frame.setSize(200, 100);
    Container contentPane = frame.getContentPane();
   
    JComboBox box = new JComboBox();
    box.addItem("123");
    box.addItem("aaa");
    box.addItem("abc");
   
    contentPane.add(box, BorderLayout.SOUTH);
    frame.show();
   
View Full Code Here


    Container contentPane = frame.getContentPane();
   
    JComboBox box = new JComboBox();
    box.addItem("123");
    box.addItem("aaa");
    box.addItem("abc");
   
    contentPane.add(box, BorderLayout.SOUTH);
    frame.show();
   
    // A new box should not be visible
View Full Code Here

    // trying out a few candidates this one seems to give the right result
    int width = fm.charWidth(' ') + additionalWidth;
    int height = fm.getHeight() + additionalHeight;
    harness.check(ui.getDisplaySize(), new Dimension(width, height));
   
    cb.addItem("ABC");
    width = fm.stringWidth("ABC") + additionalWidth;
    harness.check(ui.getDisplaySize(), new Dimension(width, height));

    cb.addItem("A longer item");
    width = fm.stringWidth("A longer item") + additionalWidth;
View Full Code Here

   
    cb.addItem("ABC");
    width = fm.stringWidth("ABC") + additionalWidth;
    harness.check(ui.getDisplaySize(), new Dimension(width, height));

    cb.addItem("A longer item");
    width = fm.stringWidth("A longer item") + additionalWidth;
    harness.check(ui.getDisplaySize(), new Dimension(width, height));

    cb.setPrototypeDisplayValue("Prototype");
    width = fm.stringWidth("Prototype") + additionalWidth;
View Full Code Here

    int height = fm.getHeight() + 2// the 2 seems to be a fixed margin
   
    // not sure why the width here needs + 1..
    harness.check(ui.getDisplaySize(), new Dimension(width + 1, height));
   
    cb.addItem("ABC");
    harness.check(ui.getDisplaySize(), new Dimension(width, height));

    cb.addItem("A longer item");
    harness.check(ui.getDisplaySize(), new Dimension(width, height));
View Full Code Here

    harness.check(ui.getDisplaySize(), new Dimension(width + 1, height));
   
    cb.addItem("ABC");
    harness.check(ui.getDisplaySize(), new Dimension(width, height));

    cb.addItem("A longer item");
    harness.check(ui.getDisplaySize(), new Dimension(width, height));

    cb.setPrototypeDisplayValue("Prototype");
    harness.check(ui.getDisplaySize(), new Dimension(width, height));
View Full Code Here

    // remove an item when it doesn't exist
    c1.removeItem("Item 1");
    harness.check(c1.getSelectedIndex(), -1);
    harness.check(c1.getSelectedItem(), null);
   
    c1.addItem("Item 1");
    harness.check(c1.getSelectedItem(), "Item 1");
    c1.addItem("Item 2");
    harness.check(c1.getSelectedItem(), "Item 1");
    c1.addItem("Item 3");
    harness.check(c1.getSelectedItem(), "Item 1");
View Full Code Here

    harness.check(c1.getSelectedIndex(), -1);
    harness.check(c1.getSelectedItem(), null);
   
    c1.addItem("Item 1");
    harness.check(c1.getSelectedItem(), "Item 1");
    c1.addItem("Item 2");
    harness.check(c1.getSelectedItem(), "Item 1");
    c1.addItem("Item 3");
    harness.check(c1.getSelectedItem(), "Item 1");
    c1.setSelectedItem("Item 3");
    harness.check(c1.getSelectedItem(), "Item 3");
View Full Code Here

   
    c1.addItem("Item 1");
    harness.check(c1.getSelectedItem(), "Item 1");
    c1.addItem("Item 2");
    harness.check(c1.getSelectedItem(), "Item 1");
    c1.addItem("Item 3");
    harness.check(c1.getSelectedItem(), "Item 1");
    c1.setSelectedItem("Item 3");
    harness.check(c1.getSelectedItem(), "Item 3");
    c1.removeItem("Item 3");
    harness.check(c1.getSelectedItem(), "Item 2");
View Full Code Here

    c1.removeItem("Item 2");
    harness.check(c1.getSelectedItem(), "Item 1");
    harness.check(c1.getSelectedIndex(), 0);
   
    c1.addItem("Item A");
    c1.removeItem("Item 1");
    harness.check(c1.getSelectedItem(), "Item A");
    harness.check(c1.getSelectedIndex(), 0);
  }
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.