Skip to content

Instantly share code, notes, and snippets.

@kaiwalyakoparkar
Last active September 30, 2021 08:27
Show Gist options
  • Select an option

  • Save kaiwalyakoparkar/0822619a5d100f3a004d6dbb729a7226 to your computer and use it in GitHub Desktop.

Select an option

Save kaiwalyakoparkar/0822619a5d100f3a004d6dbb729a7226 to your computer and use it in GitHub Desktop.
import java.awt.*;
class StudentForm {
StudentForm() {
Label l1 = new Label("Student Name:");
Label l2 = new Label("Student Age:");
Label l3 = new Label("Student DOB:");
Label l4 = new Label("Student Branch:");
Button b = new Button("Submit");
TextField t1 = new TextField();
TextField t2 = new TextField();
TextField t3 = new TextField();
TextField t4 = new TextField();
l1.setBounds(20, 80, 80, 30);
l2.setBounds(20, 80, 80, 30);
l3.setBounds(20, 80, 80, 30);
l4.setBounds(20, 80, 80, 30);
t1.setBounds(20, 100, 80, 30);
t2.setBounds(20, 100, 80, 30);
t3.setBounds(20, 100, 80, 30);
t4.setBounds(20, 100, 80, 30);
b.setBounds(100, 100, 80, 30);
this.add(b);
this.add(l1);
this.add(t1);
this.add(l2);
this.add(t2);
this.add(l3);
this.add(t3);
this.add(l4);
this.add(t4);
setLayout(new GridLayout(5,1));
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
});
}
// main method
public static void main(String args[]) {
StudentForm form = new StudentForm();
form.setVisible(true);
form.setSize(400, 400);
form.setTitle("Student Form");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment