0% found this document useful (0 votes)
6 views2 pages

Form

Uploaded by

r48167763
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Form

Uploaded by

r48167763
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import javax.swing.

*;

public class Form {

public static void main(String[] args) {

JFrame f = new JFrame("Form Example");


f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JLabel lb = new JLabel("Form Example");


lb.setBounds(50, 50, 100, 50);
f.add(lb);

JLabel lb1 = new JLabel("Name:");


lb1.setBounds(100, 100, 100, 30);
f.add(lb1);

JTextField tf = new JTextField("Enter name.");


tf.setBounds(150, 100, 90, 30);
f.add(tf);

JPasswordField pf = new JPasswordField();


JLabel lb2 = new JLabel("Password:");
lb2.setBounds(100, 150, 80, 30);
pf.setBounds(200, 150, 100, 30);
f.add(lb2);
f.add(pf);

JLabel lb3 = new JLabel("Fruits:");


lb3.setBounds(100, 200, 100, 50);
f.add(lb3);

JCheckBox cb1 = new JCheckBox("Mango");


cb1.setBounds(100, 250, 100, 50);
JCheckBox cb2 = new JCheckBox("Papaya");
cb2.setBounds(100, 300, 100, 50);
JCheckBox cb3 = new JCheckBox("Orange");
cb3.setBounds(100, 350, 100, 50);

f.add(cb1);
f.add(cb2);
f.add(cb3);

JLabel lb4 = new JLabel("Gender:");


lb4.setBounds(100, 400, 100, 50);
f.add(lb4);

JRadioButton r1 = new JRadioButton("Male");


r1.setBounds(100, 450, 100, 50);
JRadioButton r2 = new JRadioButton("Female");
r2.setBounds(100, 500, 100, 50);

ButtonGroup bg = new ButtonGroup();


bg.add(r1);
bg.add(r2);

f.add(r1);
f.add(r2);
JButton bt = new JButton("Submit");
bt.setBounds(100, 550, 100, 50);
f.add(bt);

f.setLayout(null);
f.setSize(800, 800);
f.setVisible(true);
}
}

You might also like