|
| 1 | +import javax.swing.*; |
| 2 | +import java.awt.*; |
| 3 | +public class form { |
| 4 | + public static void main(String[] args) { |
| 5 | + JFrame f=new JFrame("Registration"); |
| 6 | + |
| 7 | + JLabel lHeader=new JLabel("STUDENT'S REGISTRATION FORM"); |
| 8 | + lHeader.setBounds(200,20,300,30); |
| 9 | + f.add(lHeader); |
| 10 | + |
| 11 | + JLabel lName= new JLabel("Name : "); |
| 12 | + lName.setBounds(100,60,100,30); |
| 13 | + f.add(lName); |
| 14 | + |
| 15 | + JTextField tName=new JTextField(100); |
| 16 | + tName.setBounds(200,60,300,30); |
| 17 | + f.add(tName); |
| 18 | + |
| 19 | + JLabel lAge=new JLabel("Age : "); |
| 20 | + lAge.setBounds(100,100,100,30); |
| 21 | + f.add(lAge); |
| 22 | + |
| 23 | + /* JTextField tAge=new JTextField(80); |
| 24 | + tAge.setBounds(300,100,100,30); |
| 25 | + f.add(tAge); |
| 26 | + */ |
| 27 | + String age[]={"17","18","19","20","21"}; |
| 28 | + JComboBox cAge=new JComboBox(age); |
| 29 | + cAge.setBounds(200,100,300,30); |
| 30 | + f.add(cAge); |
| 31 | + |
| 32 | + JLabel lGender=new JLabel("Gender : "); |
| 33 | + lGender.setBounds(100,140,100,30); |
| 34 | + f.add(lGender); |
| 35 | + |
| 36 | + JRadioButton rMale=new JRadioButton("Male"); |
| 37 | + rMale.setBounds(200,140,100,30); |
| 38 | + f.add(rMale); |
| 39 | + |
| 40 | + JRadioButton rFemale=new JRadioButton("Female"); |
| 41 | + rFemale.setBounds(300,140,100,30); |
| 42 | + f.add(rFemale); |
| 43 | + |
| 44 | + JRadioButton rOthers=new JRadioButton("Others"); |
| 45 | + rOthers.setBounds(400,140,100,30); |
| 46 | + f.add(rOthers); |
| 47 | + |
| 48 | + JLabel lHobbies = new JLabel("Hobbies : "); |
| 49 | + lHobbies.setBounds(100,180,100,30); |
| 50 | + f.add(lHobbies); |
| 51 | + |
| 52 | + JCheckBox cb1=new JCheckBox("Playing"); |
| 53 | + cb1.setBounds(200,180,100,30); |
| 54 | + f.add(cb1); |
| 55 | + |
| 56 | + JCheckBox cb2=new JCheckBox("Singing"); |
| 57 | + cb2.setBounds(300,180,100,30); |
| 58 | + f.add(cb2); |
| 59 | + |
| 60 | + JCheckBox cb3=new JCheckBox("Coding"); |
| 61 | + cb3.setBounds(400,180,100,30); |
| 62 | + f.add(cb3); |
| 63 | + |
| 64 | + JLabel lCountries =new JLabel("Countries : "); |
| 65 | + lCountries.setBounds(100,220,100,30); |
| 66 | + f.add(lCountries); |
| 67 | + |
| 68 | + String [] countries={"Nepal","India","USA","England"}; |
| 69 | + JComboBox tb=new JComboBox(countries); |
| 70 | + tb.setBounds(200,220,300,30); |
| 71 | + f.add(tb); |
| 72 | + |
| 73 | + JLabel lComments =new JLabel("Comments : "); |
| 74 | + lComments.setBounds(100,260,100,30); |
| 75 | + f.add(lComments); |
| 76 | + |
| 77 | + JTextArea tComments=new JTextArea(); |
| 78 | + tComments.setBounds(200,260,300,90); |
| 79 | + f.add(tComments); |
| 80 | + |
| 81 | + JButton btn1=new JButton("SUBMIT"); |
| 82 | + JButton btn2=new JButton("CANCEL"); |
| 83 | + btn1.setBounds(220,400,100,30); |
| 84 | + btn2.setBounds(380,400,100,30); |
| 85 | + f.add(btn1); |
| 86 | + f.add(btn2); |
| 87 | + |
| 88 | + f.setLayout(null); |
| 89 | + f.setSize(600,600); |
| 90 | + f.setVisible(true); |
| 91 | + f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
| 92 | + } |
| 93 | +} |
0 commit comments