Package javax.swing

Examples of javax.swing.JComboBox.addItem()


   
    JComboBox c1 = new JComboBox();
    harness.check(c1.getSelectedIndex(), -1);
    harness.check(c1.getSelectedItem(), null);
   
    c1.addItem("Item 1");
    harness.check(c1.getSelectedIndex(), 0);
    harness.check(c1.getSelectedItem(), "Item 1");
   
    c1.addItem("Item 2");
    harness.check(c1.getSelectedIndex(), 0);
View Full Code Here


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

    c1.addItem("Item 2");
    harness.check(c1.getSelectedIndex(), 0);
    harness.check(c1.getSelectedItem(), "Item 1");
   
    // check null
    c1.addItem(null);
    harness.check(c1.getSelectedIndex(), 0);
    harness.check(c1.getSelectedItem(), "Item 1");
  }
 
}
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

    tab.gridAdd( lb, 0, row );
    ggParam  = new PrefParamField();
    ggParam.addSpace( ParamSpace.spcFreqHertz );
    ggCombo = new JComboBox();
    for( int i = 0; i < RATE_ITEMS.length; i++ ) {
      ggCombo.addItem( RATE_ITEMS[ i ]);
    }
    ggParam.setBorder( new ComboBoxEditorBorder() );
    ggCombo.setEditor( ggParam );
    ggCombo.setEditable( true );
    ggParam.setPreferences( prefs, key ); // important to be _afer_ setEditor because otherwise prefs get overwritten!
View Full Code Here

    public void actionPerformed(ActionEvent evt) {
        Object[] message = new Object[2];
        message[0] = "Choose one of the following pagesizes:";
        JComboBox cb = new JComboBox();
        for(Iterator<Object> i = options.keySet().iterator(); i.hasNext(); ) {
            cb.addItem(i.next());
        }
        message[1] = cb;
        int result = JOptionPane.showOptionDialog(
                tool.getInternalFrame(),
                message,
View Full Code Here

    public void actionPerformed(ActionEvent evt) {
        Object[] message = new Object[2];
        message[0] = "Choose one of the following options:";
        JComboBox cb = new JComboBox();
        for (Entry entry: options.values()) {
            cb.addItem(entry);
        }
        message[1] = cb;
        int result = JOptionPane.showOptionDialog(
                tool.getInternalFrame(),
                message,
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.