Example usage for java.awt List list

List of usage examples for java.awt List list

Introduction

In this page you can find the example usage for java.awt List list.

Prototype

public void list() 

Source Link

Document

Prints a listing of this component to the standard system output stream System.out .

Usage

From source file:Main.java

public static void main(String[] args) {
    Frame f = new Frame("FlowLayout demo");
    f.setLayout(new FlowLayout());
    f.add(new Button("Red"));
    f.add(new Button("Blue"));
    f.add(new Button("White"));
    List list = new List();
    for (int i = 0; i < args.length; i++) {
        list.add(args[i]);/*  w  w  w . j  a v  a 2s  . com*/
    }
    f.add(list);
    f.add(new Checkbox("Pick me", true));
    f.add(new Label("Enter name here:"));
    f.add(new TextField(20));
    f.pack();
    f.setVisible(true);
}

From source file:TreeLinkTest.java

public void init() {
    tl = new TreeLayout();
    setLayout(tl);/*from ww w.j  av  a 2s.  c o  m*/
    Button root = new Button("This is the root");
    add("Root", root);
    tl.setRoot(root);
    Component x = new Label("A random label");
    add("label", x);
    tl.setParent(x, root);
    Component y;
    y = new TextField("Add any component");
    add("comp", y);
    tl.setParent(y, root);
    x = new List();
    ((List) x).add("List entry");
    ((List) x).add("Similarly useless list entry");
    add("list", x);
    tl.setParent(x, root);
    x = new Button("Extremely long and unnecessary button title");
    add("button", x);
    tl.setParent(x, y);
    x = new MyCanvas(getImage(getDocumentBase(), "icons/tools.gif"));
    add("image", x);
    tl.setParent(x, y);
}

From source file:view.VideoPublisherGUI.java

/**
 * Initialize the contents of the frame.
 *//*from w w w . j a v  a  2 s  .com*/
private void initialize() {
    frmBlackvidPubsubber = new JFrame();
    frmBlackvidPubsubber.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            // unpublish everything
            videoPublisher.cleanup();
            // then disconnect...
            client.disconnect();
        }
    });
    frmBlackvidPubsubber.setTitle("BlackVid Publisher");
    frmBlackvidPubsubber.setBounds(100, 100, 450, 300);
    frmBlackvidPubsubber.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmBlackvidPubsubber.getContentPane().setLayout(new BorderLayout(0, 0));

    final JPanel panel = new JPanel();
    frmBlackvidPubsubber.getContentPane().add(panel, BorderLayout.SOUTH);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton publishButton = new JButton("publish video");
    publishButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            // Open file dialog
            JFileChooser chooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Video Files", "mov", "mpg", "mkv",
                    "mp4", "avi", "mpeg");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(frmBlackvidPubsubber);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                System.out
                        .println("You chose to open this file: " + chooser.getSelectedFile().getAbsolutePath());
            }

            try {
                // publish the event. Under root for now...
                String newPubIDString = rootGenerator.getNextID(chooser.getSelectedFile().getAbsolutePath(),
                        IDStrategy.RANDOM);
                videoPublisher.publishVideo(newPubIDString, chooser.getSelectedFile().getAbsolutePath());
                populatePublishList();

            } catch (DecoderException e) {
                // Report the failed event.
                JOptionPane.showConfirmDialog(panel, "Could Not Publish the Video...");
                e.printStackTrace();
            } catch (NoSuchAlgorithmException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });
    panel.add(publishButton);

    JButton unpublishButton = new JButton("unpublish");
    unpublishButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // unpublish a video.
            // check something has been selected
            String selected = getList().getSelectedItem();
            if (selected != null) {
                // get the rid
                String rid = ridMappings.get(selected);
                //unpublish by rid
                ByteIdentifier vidID;
                try {
                    videoPublisher.unpublishVideo(rid);
                } catch (DecoderException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

                populatePublishList();
            }
        }
    });

    JButton btnPublishStream = new JButton("publish stream");
    btnPublishStream.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String httpStr = JOptionPane.showInputDialog("Please enter URL of media stream.");
            System.out.println(httpStr);
            try {
                // publish the event. Under root for now...
                String newPubIDString = rootGenerator.getNextID(httpStr, IDStrategy.RANDOM);
                videoPublisher.publishVideo(newPubIDString, httpStr);
                populatePublishList();

            } catch (DecoderException e2) {
                // Report the failed event.
                JOptionPane.showConfirmDialog(panel, "Could Not Publish the Media...");
                e2.printStackTrace();
            } catch (NoSuchAlgorithmException e3) {
                // TODO Auto-generated catch block
                e3.printStackTrace();
            } catch (UnsupportedEncodingException e4) {
                // TODO Auto-generated catch block
                e4.printStackTrace();
            }
        }
    });
    panel.add(btnPublishStream);
    panel.add(unpublishButton);

    list = new List();
    frmBlackvidPubsubber.getContentPane().add(list, BorderLayout.CENTER);

    JPanel panel_1 = new JPanel();
    frmBlackvidPubsubber.getContentPane().add(panel_1, BorderLayout.NORTH);
    panel_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

}

From source file:view.VideoSubscriberGUI.java

/**
 * Initialize the contents of the frame.
 *//*from   ww  w  .j  a va 2  s . c  om*/
private void initialize() {
    frmBlackvidPubsubber = new JFrame();
    frmBlackvidPubsubber.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            // unsubscribe from catalog - just in case
            videoSubscriber.cleanup();
            // and then disconnect.
            client.disconnect();
        }
    });
    frmBlackvidPubsubber.setTitle("BlackVid Subscriber");
    frmBlackvidPubsubber.setBounds(100, 100, 450, 300);
    frmBlackvidPubsubber.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmBlackvidPubsubber.getContentPane().setLayout(new BorderLayout(0, 0));

    final JPanel panel = new JPanel();
    frmBlackvidPubsubber.getContentPane().add(panel, BorderLayout.SOUTH);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton subscribeButton = new JButton("subscribe");
    subscribeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            // check something was selected.
            String selected = list.getSelectedItem();
            if (selected != null) {
                // get the rid of the video clicked.
                String rid = ridMappings.get(selected);
                if (!videoSubscriber.subscribeVideo(rid))
                    JOptionPane.showMessageDialog(frmBlackvidPubsubber,
                            "Something went wrong with the subscription.");
            } else {
                // error
                JOptionPane.showMessageDialog(frmBlackvidPubsubber, "You must select a video from the list.");
            }
        }
    });
    panel.add(subscribeButton);

    JButton unsubscribeButton = new JButton("unsubscribe");
    unsubscribeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // check something was selected.
            String selected = list.getSelectedItem();
            if (selected != null) {
                // get the rid of the video clicked.
                String rid = ridMappings.get(selected);
                if (!videoSubscriber.unsubscribeVideo(rid))
                    JOptionPane.showMessageDialog(frmBlackvidPubsubber,
                            "Something went wrong with the subscription.\nPerhaps you had not subscribed to that video?");
            } else {
                // error
                JOptionPane.showMessageDialog(frmBlackvidPubsubber, "You must select a video from the list.");
            }
        }
    });
    panel.add(unsubscribeButton);

    list = new List();
    frmBlackvidPubsubber.getContentPane().add(list, BorderLayout.CENTER);

    JPanel panel_1 = new JPanel();
    frmBlackvidPubsubber.getContentPane().add(panel_1, BorderLayout.NORTH);
    panel_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton refreshButton = new JButton("Refresh Catalogue");
    refreshButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            // unsubscribe and then subscribe again.
            //            videoSubscriber.unsubscribeCatalog();
            videoSubscriber.subscribeCatalog();
        }
    });
    panel_1.add(refreshButton);
}