i would lik to know about well designed page
In the given code, we have used swing components to create a form on frame.
import java.sql.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class SwingFrame{ public static void main(String[] args) throws Exception{ SwingFrame sf=new SwingFrame(); } public SwingFrame(){ JFrame f = new JFrame("Frame in Java Swing"); f.getContentPane().setLayout(null); JLabel lbl1 = new JLabel("Name"); final JTextField jt1=new JTextField(15); JLabel lbl2 = new JLabel("Address"); final JPasswordField jt2=new JPasswordField(15); JLabel lbl3 = new JLabel("Contact No"); final JPasswordField jt3=new JPasswordField(15); JLabel lbl4 = new JLabel("Gender"); final JRadioButton Male,Female; ButtonGroup radioGroup=new ButtonGroup(); Male=new JRadioButton("Male"); radioGroup.add(Male); Female=new JRadioButton("Female"); radioGroup.add(Female); JButton button=new JButton("Submit"); lbl1.setBounds(50,50,70,20); lbl2.setBounds(50,90,70,20); lbl3.setBounds(50,130,70,20); lbl4.setBounds(50,170,70,20); button.setBounds(50,210,100,20); jt1.setBounds(150,50,100,20); jt2.setBounds(150,90,100,20); jt3.setBounds(150,130,100,20); Male.setBounds(150,170,100,20); Female.setBounds(250,170,100,20); f.add(lbl1); f.add(lbl2); f.add(lbl3); f.add(lbl4); f.add(jt1); f.add(jt2); f.add(jt3); f.add(Male); f.add(Female); f.add(button); f.setSize(500,500); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
Ads