[3988] in java-interest

home help back first fref pref prev next nref lref last post

Please help me add option button

daemon@ATHENA.MIT.EDU (Jonathan_Mark_Smith@CCMAIL.PRUSEC.)
Wed Dec 6 20:13:03 1995

From: Jonathan_Mark_Smith@CCMAIL.PRUSEC.COM
Date: Wed, 06 Dec 95 15:36:38 EST
To: java-interest@java.sun.com

     Can someone please show me how to turn my listbox into option buttons 
     to the following code.  Also if the you click on the submit button I 
     want to display the option thir pick.
     
     -----------------------------
     
import java.awt.*;
import java.applet.*;

public class Test extends Applet
{
        Panel infobar;
        Panel mainbar;
        TextField name;
        TextField email;
        TextField usrl;

        public void init()
        {
                setLayout(new BorderLayout());
                setBackground(Color.gray);
                setFont(new Font("Helvetica", Font.BOLD, 12));
        }

        public void start()
        {
                Panel p = new Panel();
                p.setLayout(new GridLayout(2,2));
                p.add(name = new TextField("Name", 30));
                p.add(email = new TextField("E-mail address",30));
                p.add(usrl = new TextField("URL",30));
               
                mainbar = new Panel();
                mainbar.setLayout(new BorderLayout());
                mainbar.add("West", p);

                
                List l = new List();
                l.setMultipleSelections(false);
                l.addItem("Java is Cool");
                l.addItem("This applet is cool");
                l.addItem("I want more");
                l.addItem("John is greats");
                
                add("West", l);


                add("Center", mainbar);
 
                infobar = new Panel();
                infobar.add(new Button("Send data to Site"));
                infobar.add(new Button("Clear all Fields"));
                infobar.add(new Button("Reset all Fields"));
                infobar.setBackground(Color.red);
                add("South", infobar);
        }

        public boolean action(Event evt, Object arg)
        {
                if("Send data to Site".equals(arg))
                {
                        
                        showStatus("If this worked... the data would be 
submitting");
                        return true;
                }
                else if("Clear all Fields".equals(arg))
                {
                        name.setText("");
                        email.setText("");
                        usrl.setText("");
                        return true;
                }
                else if("Reset all Fields".equals(arg))
                {
                        name.setText("Your name here please");
                        email.setText("Your e-mail address here please");
                        usrl.setText("Your URL have please");
                        return true;
                }
                else if(evt.target instanceof List)
                {
                        showStatus(arg.toString());
                        return true;
                }
                return false;           
        }

}


-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post