I was building a simple form in Java using Applet and it was showing fine, then I introduced the setLayout to Flowout and it all went blank. I thought maybe I shouldn't do that, but I set the layout back to how I had it and it still drawing a blank applet. Can you take a quick glance at this code please. Thanks
package applets;
import java.awt.*;
import java.applet.*;
public class applet3 extends Applet
{
private static final long serialVersionUID = 1L;
//creating the fields and storing variables
Button sendBtn, resetBtn;
Label nameLbl, addressLbl, cityLbl, stateLbl, zipLbl;
Label radiolblTitle, optionTitle, choiceTitle;
TextField nameTxt, addressTxt, cityTxt, stateTxt, zipTxt;
CheckboxGroup radioGroup;
Checkbox radio1, radio2;
Checkbox option1, option2, option3, option4;
Choice choice;
public void form()
{
//assigning properties to the fields
setLayout(new FlowLayout());
sendBtn = new Button("Send");
resetBtn = new Button("Reset");
nameLbl = new Label("Name");
addressLbl = new Label("Address");
cityLbl = new Label("City");
stateLbl = new Label("State");
zipLbl = new Label("Zip");
radiolblTitle = new Label("Is this a new case?");
optionTitle = new Label("Service required. Choose all that apply");
choiceTitle = new Label("Age");
nameTxt = new TextField("",50);
addressTxt = new TextField("",100);
cityTxt = new TextField("",20);
stateTxt = new TextField("",2);
zipTxt = new TextField("",5);
radioGroup = new CheckboxGroup();
radio1 = new Checkbox("Yes", radioGroup, false);
radio2 = new Checkbox("No", radioGroup, false);
option1 = new Checkbox("Criminal Law", false);
option2 = new Checkbox("Civil Law", false);
option3 = new Checkbox("Business Law", false);
option4 = new Checkbox("Divorce Law", false);
choice = new Choice();
choice.addItem("Choice 1");
choice.addItem("Choice 2");
choice.addItem("Choice 3");
//placing the fields on the applet
sendBtn.setBounds(20,580,100,30);
resetBtn.setBounds(180,580,100,30);
nameLbl.setBounds(10,70,140,30);
addressLbl.setBounds(10,105,140,30);
cityLbl.setBounds(10,140,40,30);
stateLbl.setBounds(200,140,40,30);
zipLbl.setBounds(290,140,40,30);
radiolblTitle.setBounds(10,200,120,30);
optionTitle.setBounds(10,270,250,30);
choiceTitle.setBounds(10,350,250,30);
nameTxt.setBounds(60,70,350,25);
addressTxt.setBounds(60,105,350,25);
cityTxt.setBounds(60,140,130,25);
stateTxt.setBounds(240,140,40,25);
zipTxt.setBounds(330,140,80,25);
radio1.setBounds(40,230,50,30);
radio2.setBounds(100,230,50,30);
option1.setBounds(40,300,100,30);
option2.setBounds(40,335,100,30);
option3.setBounds(180,300,100,30);
option4.setBounds(180,335,100,30);
choice.setBounds(40,370,100,30);
//activating the fields
add(sendBtn);
add(resetBtn);
add(nameTxt);
add(addressTxt);
add(cityTxt);
add(stateTxt);
add(zipTxt);
add(nameLbl);
add(addressLbl);
add(cityLbl);
add(stateLbl);
add(zipLbl);
add(radiolblTitle);
add(optionTitle);
add(choiceTitle);
add(radio1);
add(radio2);
add(option1);
add(option2);
add(option3);
add(option4);
add(choice);
}//end form
}//end class

New Topic/Question
Reply



MultiQuote






|