Example usage for java.awt Choice addItem

List of usage examples for java.awt Choice addItem

Introduction

In this page you can find the example usage for java.awt Choice addItem.

Prototype

public void addItem(String item) 

Source Link

Document

Obsolete as of Java 2 platform v1.1.

Usage

From source file:TextBouncer.java

public static void main(String[] args) {

    String s = "Java Source and Support";
    final int size = 64;
    if (args.length > 0)
        s = args[0];/* w w  w.j  a  v  a 2s  .c  om*/

    Panel controls = new Panel();
    final Choice choice = new Choice();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] allFonts = ge.getAllFonts();
    for (int i = 0; i < allFonts.length; i++)
        choice.addItem(allFonts[i].getName());
    Font defaultFont = new Font(allFonts[0].getName(), Font.PLAIN, size);

    final TextBouncer bouncer = new TextBouncer(s, defaultFont);
    Frame f = new AnimationFrame(bouncer);
    f.setFont(new Font("Serif", Font.PLAIN, 12));
    controls.add(bouncer.createCheckbox("Antialiasing", TextBouncer.ANTIALIASING));
    controls.add(bouncer.createCheckbox("Gradient", TextBouncer.GRADIENT));
    controls.add(bouncer.createCheckbox("Shear", TextBouncer.SHEAR));
    controls.add(bouncer.createCheckbox("Rotate", TextBouncer.ROTATE));
    controls.add(bouncer.createCheckbox("Axes", TextBouncer.AXES));

    Panel fontControls = new Panel();
    choice.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ie) {
            Font font = new Font(choice.getSelectedItem(), Font.PLAIN, size);
            bouncer.setFont(font);
        }
    });
    fontControls.add(choice);

    Panel allControls = new Panel(new GridLayout(2, 1));
    allControls.add(controls);
    allControls.add(fontControls);
    f.add(allControls, BorderLayout.NORTH);
    f.setSize(300, 300);
    f.setVisible(true);
}

From source file:SumUp.java

/** init() is an Applet method called by the browser to initialize */
public void init() {
    setBackground(Color.magenta);
    // The layout of the Applet is a Grid; always add things in pairs!
    setLayout(new GridLayout(0, 2));
    Choice c;
    add(new Label("Option 1"));
    add(c = new Choice());
    c.addItem("0");
    c.addItem("100");
    c.addItem("200");
    c.addItem("400");
    cs[numChoices++] = c;/*from   w  ww  .j a v a  2s . co  m*/

    add(new Label("Option 2"));
    add(c = new Choice());
    c.addItem("0");
    c.addItem("100");
    c.addItem("200");
    c.addItem("400");
    cs[numChoices++] = c;

    Panel p = new Panel();
    p.setBackground(Color.pink);
    p.add(new Label("Total:"));
    p.add(resultField = new Label("000000"));
    add(p);

    sendButton = new Button("Send it");
    add(sendButton); // connect Button into Applet
    sendButton.addActionListener(this); // connect it back to Applet
}

From source file:mesquite.zephyr.lib.GarliRunner.java

public void preparePartitionChoice(Choice partitionChoice, int partitionScheme) {
    partitionChoice.removeAll();//w  w  w .  j  a va  2  s .co m

    switch (partitionScheme) {
    case partitionByCharacterGroups:
        ZephyrUtil.setPartitionChoice(data, partitionChoice);
        break;
    case partitionByCodonPosition:
        partitionChoice.addItem(codpos1Subset);
        partitionChoice.addItem(codpos2Subset);
        partitionChoice.addItem(codpos3Subset);
        partitionChoice.addItem(nonCodingSubset);
        break;
    case noPartition:
        partitionChoice.addItem("All Characters");
        break;
    default:
        partitionChoice.addItem("All Characters");
    }
}