Example usage for java.awt Choice add

List of usage examples for java.awt Choice add

Introduction

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

Prototype

public void add(String item) 

Source Link

Document

Adds an item to this Choice menu.

Usage

From source file:ImageBouncer.java

public static void main(String[] args) {
    String filename = "java2sLogo.png";
    if (args.length > 0)
        filename = args[0];/*from  w  w w.  ja  va  2s  . c om*/

    Image image = null;
    try {
        image = blockingLoad(new URL(filename));
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    final ImageBouncer bouncer = new ImageBouncer(image);
    Frame f = new AnimationFrame(bouncer);
    f.setFont(new Font("Serif", Font.PLAIN, 12));
    Panel controls = new Panel();
    controls.add(bouncer.createCheckbox("Bilinear", ImageBouncer.BILINEAR));
    controls.add(bouncer.createCheckbox("Transform", ImageBouncer.TRANSFORM));
    final Choice typeChoice = new Choice();
    typeChoice.add("TYPE_INT_RGB");
    typeChoice.add("TYPE_INT_ARGB");
    typeChoice.add("TYPE_INT_ARGB_PRE");
    typeChoice.add("TYPE_3BYTE_BGR");
    typeChoice.add("TYPE_BYTE_GRAY");
    typeChoice.add("TYPE_USHORT_GRAY");
    typeChoice.add("TYPE_USHORT_555_RGB");
    typeChoice.add("TYPE_USHORT_565_RGB");
    controls.add(typeChoice);
    f.add(controls, BorderLayout.NORTH);

    typeChoice.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ie) {
            String type = typeChoice.getSelectedItem();
            bouncer.setImageType(type);
        }
    });
    f.setSize(200, 200);
    f.setVisible(true);
}

From source file:Presentation.MainWindow.java

/** Ajout  la fentre de la liste de ports COM dtectes par l'ordinateur pour rcuprer les donnes */
public void addCOMPorts(ArrayList<String> Ports) {
    Panel panel = new Panel();
    Label label = new Label("Ports COM");

    Choice COMPorts = new Choice();

    for (String port : Ports) {
        COMPorts.add(port);
    }//www .  ja  v a2  s .  co  m

    panel.add(label);
    panel.add(COMPorts);

    mPanel.add(panel);

    show();
}