Package java.awt

Examples of java.awt.Panel


         addNotify();
         addWindowListener(new Close());
         setLayout(new BorderLayout());

         Panel p = new Panel(new GridLayout(3, 1));
         p.add(line1 = new Label());
         p.add(line2 = new Label());
         p.add(line3 = new Label());
         add("North", p);

         p = new Panel(new GridLayout(2, 1));
         p.add(new Label("Username:"));
         p.add(new Label("Password:"));
         add("West", p);
         p = new Panel(new GridLayout(2, 1));
         p.add(user = new TextField(30));
         p.add(pass = new TextField(30));
         pass.addActionListener(new Ok());
         pass.setEchoChar('*');
         add("East", p);

         GridBagLayout gb = new GridBagLayout();
         p = new Panel(gb);
         GridBagConstraints constr = new GridBagConstraints();
         Panel pp = new Panel();
         p.add(pp);
         constr.gridwidth = GridBagConstraints.REMAINDER;
         gb.setConstraints(pp, constr);
         constr.gridwidth = 1;
         constr.weightx = 1.0;
View Full Code Here


      constr.gridwidth = GridBagConstraints.REMAINDER;
      constr.anchor = GridBagConstraints.WEST;
      add(new Label("The server would like to set the following cookie:"), constr);

      Panel p = new Panel();
      left_panel = new Panel();
      left_panel.setLayout(new GridLayout(4, 1));
      left_panel.add(new Label("Name=Value:"));
      left_panel.add(new Label("Domain:"));
      left_panel.add(new Label("Path:"));
      left_panel.add(new Label("Expires:"));
      ports_label = new Label("Ports:");
      p.add(left_panel);

      right_panel = new Panel();
      right_panel.setLayout(new GridLayout(4, 1));
      right_panel.add(name_value_label = new Label());
      right_panel.add(domain_value = new Label());
      right_panel.add(path_value = new Label());
      right_panel.add(expires_value = new Label());
      ports_value = new Label();
      p.add(right_panel);
      add(p, constr);
      secure_note = new Label("This cookie will only be sent over secure connections");
      discard_note = new Label("This cookie will be discarded at the end of the session");
      c_url_note = new Label("");
      comment_label = new Label("Comment:");
      comment_value = new TextArea("", 3, 45, TextArea.SCROLLBARS_VERTICAL_ONLY);
      comment_value.setEditable(false);

      add(new Panel(), constr);

      constr.gridwidth = 1;
      constr.anchor = GridBagConstraints.CENTER;
      constr.weightx = 1.0;
      add(default_focus = new Button("Accept"), constr);
      default_focus.addActionListener(new Accept());

      Button b;
      constr.gridwidth = GridBagConstraints.REMAINDER;
      add(b = new Button("Reject"), constr);
      b.addActionListener(new Reject());

      constr.weightx = 0.0;
      p = new Separator();
      constr.fill = GridBagConstraints.HORIZONTAL;
      add(p, constr);

      constr.fill = GridBagConstraints.NONE;
      constr.anchor = GridBagConstraints.WEST;
      add(new Label("Accept/Reject all cookies from a host or domain:"), constr);

      p = new Panel();
      p.add(new Label("Host/Domain:"));
      p.add(domain = new TextField(30));
      add(p, constr);

      add(new Label("domains are characterized by a leading dot (`.');"), constr);
      add(new Label("an empty string matches all hosts"), constr);
View Full Code Here

    @SuppressWarnings("serial")
    static class ListWindow extends SubFrame {
        public void init() {
            initted = true;

            Panel p = new Panel();
            p.setLayout(new GridLayout(3, 1));

            List l = new List(5, true);
            for (int i = 0; i < 10; i++)
                l.add("List item " + i);

            p.add(l);

            add(p, "Center");

            Button cb = new Button("Close");
            cb.addActionListener(new ActionListener() {
View Full Code Here

    @SuppressWarnings("serial")
    static class RadioWindow extends SubFrame {
        public void init() {
            initted = true;

            Panel p = new Panel();
            p.setLayout(new GridLayout(3, 1));
            ((GridLayout) p.getLayout()).setHgap(5);
            ((GridLayout) p.getLayout()).setVgap(5);

            final CheckboxGroup cg = new CheckboxGroup();
            final Checkbox[] boxes = new Checkbox[3];
            for (int i = 0; i < 3; ++i) {
                boxes[i] = new Checkbox("button" + i, cg, i == 0);
                p.add(boxes[i]);
            }

            add(p, "North");

            p = new Panel();
            p.setLayout(new GridLayout(1, 3));
            ((GridLayout) p.getLayout()).setHgap(5);
            ((GridLayout) p.getLayout()).setVgap(5);

            for (int i = 0; i < 3; ++i) {
                final int val = i;
                Button tweak = new Button("Set " + i);
                tweak.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        cg.setSelectedCheckbox(boxes[val]);
                    }
                });
                p.add(tweak);
            }

            add(p, "Center");

            Button cb = new Button("Close");
View Full Code Here

                public void windowClosing(WindowEvent e) {
                    setVisible(false);
                }
            });

            Panel pan = new Panel();

            final Label l = new Label("Pithy Message:");
            l.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            pan.add(l);

            TextField tf = new TextField("Hello world!");
            pan.add(tf);
            add(pan, "North");

            final Image img;
            URL imageurl;
            imageurl = this.getClass().getResource(
                "/gnu/classpath/examples/icons/big-warning.png");
            img = Toolkit.getDefaultToolkit().createImage(imageurl);

            final Canvas ch = new Canvas() {
                public void paint(Graphics g) {
                    g.drawImage(img, xs + 25, ys + 25, this);

                    Font font = new Font("Serif", Font.PLAIN, 18);
                    g.setFont(font);
                    g.setXORMode(Color.red);

                    g.drawString("Hi Red!", xs + 15, ys + 10);
                    g.setColor(Color.blue);
                    g.drawLine(xs, ys, xs + 100, ys + 100);

                }
            };
            ch.setSize(150, 150);
            add(ch, "Center");

            final ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
            final Panel p = new Panel();
            p.add(new Button("Stop"));
            p.add(new Button("evil"));
            p.add(new Button("hoarders"));
            p.add(new Button("use"));
            p.add(new Button("GNU!"));

            sp.add(p);
            add(sp, "South");

            Panel east_panel = new Panel();
            east_panel.setLayout(new GridLayout(0, 1));

            CheckboxGroup group = new CheckboxGroup();
            Checkbox cb = new Checkbox("one", group, true);
            east_panel.add(cb);
            cb = new Checkbox("two", group, false);
            east_panel.add(cb);

            add(east_panel, "East");

            final Button wb = new Button();
            wb.setLabel("Hello World!");
View Full Code Here

            addSubWindow("Radio Buttons", new RadioWindow());
            addSubWindow("TextField", new TextFieldWindow());
            addSubWindow("RandomTests", new TestWindow(this));
            addSubWindow("RoundRect", new RoundRectWindow());

            Panel sp = new Panel();
            PrettyPanel p = new PrettyPanel();
            p.setLayout(new GridLayout(windows.size(), 1));

            for (Button b : buttons) {
                p.add(b);
            }

            sp.add(p);
            add(sp, "Center");

            setTitle("AWT Demo");
            pack();
        }
View Full Code Here

    static class ButtonsWindow extends SubFrame implements ActionListener {
        Button b[] = new Button[9];

        public void init() {
            initted = true;
            Panel p = new Panel();
            p.setLayout(new GridLayout(0, 3, 5, 5));

            for (int i = 0; i < 9; i++) {
                b[i] = new Button("button" + (i + 1));
                b[i].addActionListener(this);
            }

            p.add(b[0]);
            p.add(b[6]);
            p.add(b[4]);
            p.add(b[8]);
            p.add(b[1]);
            p.add(b[7]);
            p.add(b[3]);
            p.add(b[5]);
            p.add(b[2]);

            add(p, "North");

            Button cb = new Button("close");
            cb.addActionListener(new ActionListener() {
View Full Code Here

            text.setAlignment(Label.CENTER);

            add(text, "North");
            text.setVisible(false);

            Panel p = new PrettyPanel();

            Button cb = new Button("OK");
            cb.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    text.setVisible(false);
                    setVisible(false);
                }
            });

            p.setLayout(new GridLayout(1, 3));
            ((GridLayout) p.getLayout()).setHgap(5);
            ((GridLayout) p.getLayout()).setVgap(5);
            p.add(cb);

            Button toggle = new Button("Toggle");
            p.add(toggle);

            toggle.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if (text.isVisible())
                        text.setVisible(false);
                    else
                        text.setVisible(true);
                    doLayout();
                }
            });

            Button subdlg = new Button("SubDialog");
            p.add(subdlg);

            subdlg.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    DialogWindow sw = new DialogWindow(parent);
                    sw.setVisible(true);
View Full Code Here

        public void init() {
            initted = true;
            text = new TextField("hello world");
            add(text, "North");

            Panel p = new Panel();
            p.setLayout(new GridLayout(3, 1));
            ((GridLayout) p.getLayout()).setHgap(5);
            ((GridLayout) p.getLayout()).setVgap(5);

            editable = new Checkbox("Editable", true);
            p.add(editable);
            editable.addItemListener(this);

            visible = new Checkbox("Visible", true);
            p.add(visible);
            visible.addItemListener(this);

            sensitive = new Checkbox("Sensitive", true);
            p.add(sensitive);
            sensitive.addItemListener(this);

            add(p, "Center");

            Button cb = new Button("Close");
View Full Code Here

    @SuppressWarnings("serial")
    static class LabelWindow extends SubFrame {
        public void init() {
            initted = true;

            Panel p = new Panel();
            p.setLayout(new GridLayout(3, 1));
            ((GridLayout) p.getLayout()).setHgap(5);
            ((GridLayout) p.getLayout()).setVgap(5);

            p.add(new Label("left justified label", Label.LEFT));
            p.add(new Label("center justified label", Label.CENTER));
            p.add(new Label("right justified label", Label.RIGHT));

            add(p, "Center");

            Button cb = new Button("Close");
            cb.addActionListener(new ActionListener() {
View Full Code Here

TOP

Related Classes of java.awt.Panel

Copyright © 2018 www.massapicom. 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.