Example usage for com.google.gwt.user.client.ui ListBox addItem

List of usage examples for com.google.gwt.user.client.ui ListBox addItem

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui ListBox addItem.

Prototype

public void addItem(String item) 

Source Link

Document

Adds an item to the list box.

Usage

From source file:ace.client.JSEditorToolbar.java

License:Apache License

private ListBox createColorList(String caption) {
    ListBox lb = new ListBox();
    lb.addChangeHandler(handler);/*  www.j  a  v  a 2  s .c o  m*/
    lb.setVisibleItemCount(1);

    lb.addItem(caption);
    /*
        lb.addItem(strings.white(), "white");
        lb.addItem(strings.black(), "black");
        lb.addItem(strings.red(), "red");
        lb.addItem(strings.green(), "green");
        lb.addItem(strings.yellow(), "yellow");
        lb.addItem(strings.blue(), "blue");
    */
    return lb;
}

From source file:asquare.gwt.tests.focus.client.Demo.java

License:Apache License

private Widget createFocusPanel() {
    Table outer = new Table();

    outer.add(new FocusPanel(new Label("Label in a FocusPanel")));
    outer.add(new Button("Button"));
    outer.add(new CheckBox("CheckBox"));
    outer.add(new TextBox());
    outer.add(new PasswordTextBox());
    outer.add(new TextArea());
    outer.add(new RadioButton("group1", "RadioButton1"));
    outer.add(new RadioButton("group1", "RadioButton2"));
    ListBox listBox1 = new ListBox();
    listBox1.addItem("ListBox1");
    listBox1.addItem("item2");
    listBox1.addItem("item3");
    outer.add(listBox1);/* w w  w  . j ava 2  s . c  o m*/
    ListBox listBox2 = new ListBox(true);
    listBox2.setVisibleItemCount(3);
    listBox2.addItem("ListBox2");
    listBox2.addItem("item2");
    listBox2.addItem("item3");
    outer.add(listBox2);
    Tree tree = new Tree();
    tree.addItem("Tree");
    tree.addItem("item2");
    tree.addItem("item3");
    outer.add(tree);

    return outer;
}

From source file:asquare.gwt.tests.focusevent.client.Demo.java

License:Apache License

private Widget createDemoPanel() {
    TestPanel outer = new TestPanel();

    outer.add(new Label("GWT onfocus Event Handler"));
    outer.add(new Button("Button"), "Button");
    outer.add(new CheckBox("CheckBox"), "CheckBox");
    outer.add(new RadioButton("group1", "RadioButton1"), "RadioButton1");
    TextBox textBox = new TextBox();
    textBox.setText("TextBox");
    outer.add(textBox, "TextBox");
    PasswordTextBox passwordTextBox = new PasswordTextBox();
    passwordTextBox.setText("PasswordTextBox");
    outer.add(passwordTextBox, "PasswordTextBox");
    TextArea textArea = new TextArea();
    textArea.setText("TextArea");
    outer.add(textArea, "TextArea");
    ListBox listBox = new ListBox();
    listBox.addItem("ListBox");
    listBox.addItem("item2");
    listBox.addItem("item3");
    outer.add(listBox, "ListBox");
    outer.add(new FocusPanel(new Label("Label in a FocusPanel")), "FocusPanel");
    Tree tree = new Tree();
    tree.addItem("item1");
    tree.addItem("item2");
    tree.addItem("item3");
    outer.add(tree, "Tree");

    return outer;
}

From source file:asquare.gwt.tk.demo.client.DebugPanel.java

License:Apache License

private Widget createWidgetPanel() {
    BasicPanel widgets = new BasicPanel();
    DOM.setAttribute(widgets.getElement(), "id", "debug-widgets");
    TextArea textArea = new TextArea();
    textArea.setText("Enable event tracing then type in here");
    widgets.add(textArea);/*from ww w  . j  a va 2  s .  c  om*/

    ListBox listBox = new ListBox();
    listBox.addItem("List Box");
    listBox.addItem("foo");
    listBox.addItem("bar");
    listBox.addItem("baz");
    widgets.add(listBox);

    TreeItem treeRoot = new TreeItem("Tree");
    TreeItem treeItem = new TreeItem("foo");
    treeRoot.addItem(treeItem);
    treeRoot.addItem("bar");
    treeRoot.addItem("baz");
    Tree tree = new Tree();
    tree.addItem(treeRoot);
    tree.setSelectedItem(treeItem);
    tree.ensureSelectedItemVisible();
    widgets.add(tree);

    Image image = new Image("icecube.jpg");
    ScrollPanel scrollPanel = new ScrollPanel(image);
    scrollPanel.setSize("200px", "200px");
    widgets.add(scrollPanel);

    return widgets;
}

From source file:asquare.gwt.tk.uitest.popuppanel.client.Demo.java

License:Apache License

private Widget createTransparencyTest() {
    RowPanel outer = new RowPanel();
    BasicToolTip toolTip = new BasicToolTip();
    Controller ttController = new BasicToolTipController(toolTip);

    outer.add(new HTML("<h3>Popup transparency</h3><p>Hover over a widget</p>"));

    ListBox list = new ListBox(true);
    list.setVisibleItemCount(4);//from   w  ww.  j av a2s  . co m
    list.addItem("ListBox");
    list.addItem("1");
    list.addItem("2");
    list.addItem("3");
    list.addItem("4");
    list.addItem("5");
    outer.add(new ToolTipWrapper(list, "Popup transparency over a ListBox").addController(ttController));

    outer.add(new ToolTipWrapper(new Frame("FrameContents.html"), "Popup transparency over a Frame")
            .addController(ttController));

    outer.add(new ToolTipWrapper(new RadioButton("radioGroup", "RadioButton a"), "Choice a")
            .addController(ttController));
    outer.add(new ToolTipWrapper(new RadioButton("radioGroup", "RadioButton b"), "Choice b")
            .addController(ttController));
    outer.add(new ToolTipWrapper(new RadioButton("radioGroup", "RadioButton c"), "Choice c")
            .addController(ttController));
    return outer;
}

From source file:asquare.gwt.tkdemo.client.demos.DebugPanel.java

License:Apache License

private Widget createWidgetPanel() {
    BasicPanel widgets = new BasicPanel();
    TextArea textArea = new TextArea();
    textArea.setText("Enable event tracing then type in here");
    widgets.add(textArea);//from ww  w  .j  av a 2  s  .c  om

    ListBox listBox = new ListBox();
    listBox.addItem("List Box");
    listBox.addItem("foo");
    listBox.addItem("bar");
    listBox.addItem("baz");
    widgets.add(listBox);

    TreeItem treeRoot = new TreeItem("Tree");
    final TreeItem treeItem = new TreeItem("foo");
    treeRoot.addItem(treeItem);
    treeRoot.addItem("bar");
    treeRoot.addItem("baz");
    final Tree tree = new Tree();
    tree.addItem(treeRoot);
    /*
       * This crashes the hosted shell
       * http://code.google.com/p/google-web-toolkit/issues/detail?id=1785
     */
    //        /*
    //         * Defer selection so that Tree does not break Opera
    //         * http://code.google.com/p/google-web-toolkit/issues/detail?id=1784
    //       */
    //        DeferredCommand.addCommand(new Command()
    //        {
    //            public void execute()
    //            {
    //                tree.setSelectedItem(treeItem);
    //                tree.ensureSelectedItemVisible();
    //            }
    //        });
    widgets.add(tree);

    Image image = new Image("icecube.jpg");
    ScrollPanel scrollPanel = new ScrollPanel(image);
    scrollPanel.setSize("200px", "200px");
    widgets.add(scrollPanel);

    return widgets;
}

From source file:asquare.gwt.tkdemo.client.demos.DialogPanel.java

License:Apache License

private Widget createModalDialogDemo() {
    BasicPanel panel = new BasicPanel("div", "block");
    panel.setStyleName("example division");
    DomUtil.setStyleAttribute(panel, "whiteSpace", "nowrap");

    panel.add(new HTML("<h4>ModalDialog examples</h4>"));

    class CloseListener implements ClickHandler {
        private final ModalDialog m_dialog;

        public CloseListener(ModalDialog dialog) {
            m_dialog = dialog;/*from w  w w .j  a v  a2s  .  c  o m*/
        }

        public void onClick(ClickEvent event) {
            m_dialog.hide();
        }
    }

    class CloseButton extends Button {
        public CloseButton(ModalDialog dialog) {
            super("Close");
            addClickHandler(new CloseListener(dialog));
        }

        public CloseButton(ModalDialog dialog, String text) {
            super(text);
            addClickHandler(new CloseListener(dialog));
        }
    }

    final Button plainDialog = new Button("Plain");
    plainDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.setCaption("Caption area", false);
            dialog.add(new Label("Content area"));
            dialog.add(new CloseButton(dialog));
            dialog.show(plainDialog);
        }
    });
    panel.add(plainDialog);

    final Button verboseDialog = new Button("Verbose");
    verboseDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.setCaption("Verbose dialog", false);
            dialog.add(new Label("Twas brillig, and the slithy toves " + "  Did gyre and gimble in the wabe: "
                    + "All mimsy were the borogoves, " + "  And the mome raths outgrabe "
                    + "Beware the Jabberwock, my son! " + "The jaws that bite, the claws that catch! "
                    + "Beware the Jubjub bird, and shun " + "The frumious Bandersnatch!"));
            dialog.add(new CloseButton(dialog));
            dialog.show(verboseDialog);
        }
    });
    panel.add(verboseDialog);

    final Button captionLessDialog = new Button("No caption");
    captionLessDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.add(new Label("Captionless dialog"));
            dialog.add(new CloseButton(dialog));
            dialog.show(captionLessDialog);
        }
    });
    panel.add(captionLessDialog);

    final Button loadingDialog = new Button("Loading...");
    loadingDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            final Label label = new Label("0% loaded");
            dialog.add(label);
            dialog.show(loadingDialog);
            new Timer() {
                private int m_count = 0;

                public void run() {
                    label.setText(++m_count + "% loaded");
                    if (m_count == 100) {
                        dialog.hide();
                        cancel();
                    }
                }
            }.scheduleRepeating(1);
        }
    });
    panel.add(loadingDialog);

    final Button undraggableDialog = new Button("Drag disabled");
    undraggableDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog() {
                protected List<Controller> createCaptionControllers() {
                    List<Controller> result = new ArrayList<Controller>();
                    result.add(ControlSurfaceController.getInstance());
                    return result;
                }
            };
            dialog.setCaption("Drag disabled", false);
            dialog.add(new Label(
                    "This dialog uses a custom controller in the header which does not provide drag support."));
            dialog.add(new CloseButton(dialog));
            dialog.show(undraggableDialog);
        }
    });
    panel.add(undraggableDialog);

    final Button styledDragDialog = new Button("Drag style");
    styledDragDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            String oldPrimaryName = dialog.getStylePrimaryName();
            dialog.setStylePrimaryName("dialog-dragstyle");
            dialog.addStyleName(oldPrimaryName);
            dialog.setCaption("Drag me", false);
            dialog.add(new Label(
                    "This dialog employs the \"tk-ModalDialog-dragging\" style which is applied while dragging. "));
            dialog.add(new CloseButton(dialog));
            dialog.show(styledDragDialog);
        }
    });
    panel.add(styledDragDialog);

    final Button focusManagementDialog = new Button("Focus management");
    focusManagementDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.setCaption("Register", false);
            FocusModel fModel = dialog.getFocusModel();

            final int FIELD_COUNT = 3;
            Grid table = new Grid(FIELD_COUNT, 2);
            dialog.add(table);
            Widget[] labels = new Widget[FIELD_COUNT];
            labels[0] = new Label("User name: ");
            labels[1] = new Label("Password: ");
            labels[2] = new Label("Retype password: ");

            FocusWidget[] fields = new FocusWidget[FIELD_COUNT];
            fields[0] = new TextBox();
            fields[1] = new PasswordTextBox();
            fields[2] = new PasswordTextBox();

            CellFormatter formatter = table.getCellFormatter();
            for (int i = 0; i < labels.length; i++) {
                table.setWidget(i, 0, labels[i]);
                formatter.setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_LEFT);
                table.setWidget(i, 1, fields[i]);

                /*
                 * Manually add fields to focus cycle. (The dialog does not
                 * scan the children of panels for focusable widgets.)
                 */
                fModel.add(fields[i]);
            }

            // this widget will be focused when the dialog is shown
            fModel.setFocusWidget(fields[0]);

            ColumnPanel buttonPanel = new ColumnPanel();
            buttonPanel.setWidth("100%");
            dialog.add(buttonPanel);

            Button closeButton = new CloseButton(dialog, "Register!");
            fModel.add(closeButton);
            buttonPanel.add(closeButton);

            Button cancelButton = new CloseButton(dialog, "Cancel");
            fModel.add(cancelButton);
            buttonPanel.addWidget(cancelButton, false);
            buttonPanel.setCellHorizontalAlignment(ColumnPanel.ALIGN_RIGHT);

            dialog.show(focusManagementDialog);
        }
    });
    panel.add(focusManagementDialog);

    final Button explicitlyPositionedDialog = new Button("Explicitly positioned");
    explicitlyPositionedDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.removeController(dialog.getController(ModalDialog.PositionDialogController.class));
            int contentWidth = 300;
            int contentHeight = 100;
            dialog.setContentWidth(contentWidth + "px");
            dialog.setContentHeight(contentHeight + "px");
            dialog.setPopupPosition(100, 100);
            dialog.setCaption("Explicitly positioned dialog", false);
            dialog.add(new Label(
                    "Automatic positioning is disabled. Dimensions and position are set explicitly. "));
            dialog.add(new CloseButton(dialog));
            dialog.show(explicitlyPositionedDialog);
        }
    });
    panel.add(explicitlyPositionedDialog);

    final Button multipleDialogs = new Button("Multiple dialogs");
    multipleDialogs.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            ModalDialog dialog = new ModalDialog();
            dialog.setCaption("First dialog", false);
            FocusModel fModel = dialog.getFocusModel();
            RowPanel outer = new RowPanel();

            dialog.add(new HTML(""));

            final UrlLocation urlBox = new UrlLocation();
            urlBox.setText("http://www.asquare.net");
            urlBox.setWidth("350px");
            fModel.add(urlBox);
            outer.add(urlBox);

            Button goButton = new Button("Go");
            fModel.add(goButton);
            fModel.setFocusWidget(goButton);
            outer.addWidget(goButton, false);

            ListBox addressList = new ListBox();
            addressList.addItem("Select an address");
            addressList.addItem("http://www.asquare.net");
            addressList.addItem("http://www.google.com");
            addressList.addItem("http://www.sourceforge.net");
            addressList.addItem("http://www.apache.org");
            fModel.add(addressList);
            outer.add(addressList);

            final Frame frame = new Frame();
            frame.setSize("400px", "200px");
            outer.add(frame);
            urlBox.addChangeHandler(new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    frame.setUrl(urlBox.getURL());
                }
            });
            goButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    frame.setUrl(urlBox.getURL());
                }
            });
            addressList.addChangeHandler(new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    ListBox list = (ListBox) event.getSource();
                    if (list.getSelectedIndex() > 0) {
                        urlBox.setText(list.getItemText(list.getSelectedIndex()));
                        frame.setUrl(list.getItemText(list.getSelectedIndex()));
                    }
                }
            });
            final Button secondDialog = new Button("Show second dialog");
            secondDialog.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    final ModalDialog dialog = new ModalDialog();
                    dialog.setCaption("Second dialog", false);
                    dialog.add(new Label("Note that you cannot manipulate the widgets in the first dialog. "));
                    dialog.add(new CloseButton(dialog));
                    dialog.show(secondDialog);
                }
            });
            fModel.add(secondDialog);
            outer.add(secondDialog);
            Button closeButton = new CloseButton(dialog);
            fModel.add(closeButton);
            outer.add(closeButton);
            dialog.add(outer);
            dialog.show(multipleDialogs);
        }
    });
    panel.add(multipleDialogs);

    final Button styledDialog = new Button("Styled");
    styledDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.addStyleName("dialog-styled");
            HorizontalPanel caption = new HorizontalPanel();
            caption.setWidth("100%");
            Label captionText = new Label("Oopsie!");
            caption.add(captionText);
            caption.setCellWidth(captionText, "100%");
            Image close = new Image("close.gif");
            close.addClickHandler(new CloseListener(dialog));
            caption.add(close);
            dialog.setCaption(caption);
            dialog.add(new Label("I've been a bad, bad browser."));
            dialog.add(new Button("Deny ice cream", new CloseListener(dialog)));
            dialog.show(styledDialog);
        }
    });
    panel.add(styledDialog);

    return panel;
}

From source file:asquare.gwt.tkdemo.client.demos.FocusCycleDemo.java

License:Apache License

private Widget createFocusCycle1() {
    FocusCyclePanel cycle1 = new FocusCyclePanel("div", "block");

    cycle1.add(new Label("Cycle 1"));

    cycle1.add(new FocusStyleDecorator(new Button("Button")));

    Button buttonDisabled = new Button("disabled");
    buttonDisabled.setEnabled(false);/*ww  w. j  a  v a2s. c  o  m*/
    cycle1.add(new FocusStyleDecorator(buttonDisabled));

    Button buttonNegativeTabIndex = new Button("tabIndex = -1");
    buttonNegativeTabIndex.setTabIndex(-1);
    cycle1.add(new FocusStyleDecorator(buttonNegativeTabIndex));

    cycle1.add(new FocusStyleDecorator(new CheckBox("CheckBox")));

    cycle1.add(new FocusStyleDecorator(new FocusPanel(new Label("FocusPanel"))));

    ListBox listBox = new ListBox();
    listBox.addItem("ListBox");
    listBox.addItem("Item 1");
    listBox.addItem("Item 2");
    listBox.addItem("Item 3");
    cycle1.add(new FocusStyleDecorator(listBox));

    TextBox textBox = new TextBox();
    textBox.setText("TextBox");
    cycle1.add(new FocusStyleDecorator(textBox));

    PasswordTextBox pwBox = new PasswordTextBox();
    pwBox.setText("PasswordTextBox");
    cycle1.add(new FocusStyleDecorator(pwBox));

    TextArea textArea = new TextArea();
    textArea.setText("TextArea");
    cycle1.add(new FocusStyleDecorator(textArea));

    Tree tree = new Tree();
    TreeItem treeRoot = new TreeItem("Tree");
    for (int branchNum = 1; branchNum < 4; branchNum++) {
        TreeItem branch = new TreeItem("Branch " + branchNum);
        for (int item = 1; item < 4; item++) {
            branch.addItem("Item " + item);
        }
        treeRoot.addItem(branch);
    }
    tree.addItem(treeRoot);
    cycle1.add(new FocusStyleDecorator(tree));

    new WidgetFocusStyleController(cycle1.getFocusModel());

    return cycle1;
}

From source file:at.ac.fhcampuswien.atom.client.gui.attributes.components.RichTextToolbar.java

License:Open Source License

/** Method to create the fontlist for the toolbar **/
private ListBox createFontList() {
    ListBox mylistBox = new ListBox();
    mylistBox.addChangeHandler(evHandler);
    mylistBox.setVisibleItemCount(1);//from  w  w w.j  av a  2  s  .  c  om

    mylistBox.addItem(GUI_LISTNAME_FONTS);
    for (String name : GUI_FONTLIST.keySet()) {
        mylistBox.addItem(name, GUI_FONTLIST.get(name));
    }

    return mylistBox;
}

From source file:at.ac.fhcampuswien.atom.client.gui.attributes.components.RichTextToolbar.java

License:Open Source License

/** Method to create the colorlist for the toolbar **/
private ListBox createColorList() {
    ListBox mylistBox = new ListBox();
    mylistBox.addChangeHandler(evHandler);
    mylistBox.setVisibleItemCount(1);/*from w ww.  ja  va2 s . c  om*/

    mylistBox.addItem(GUI_LISTNAME_COLORS);
    for (String name : GUI_COLORLIST.keySet()) {
        mylistBox.addItem(name, GUI_COLORLIST.get(name));
    }

    return mylistBox;
}