0% found this document useful (0 votes)
55 views

Java Programs Booklet

This document contains the code for a Java student registration form applet. It defines a student class that extends Frame and implements ActionListener. The class contains code to create and position GUI elements like labels, text fields, checkboxes and buttons to collect student registration information like name, gender, branch. It also contains code to handle button click events and close the window.

Uploaded by

Shivank Agarwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Java Programs Booklet

This document contains the code for a Java student registration form applet. It defines a student class that extends Frame and implements ActionListener. The class contains code to create and position GUI elements like labels, text fields, checkboxes and buttons to collect student registration information like name, gender, branch. It also contains code to handle button click events and close the window.

Uploaded by

Shivank Agarwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.awt.*; import java.applet.*; import java.awt.event.

*; public class student extends Frame implements ActionListener { String msg; Label l11=new Label("STUDENT REGISTRATION FORM",Label.CENTER); Label l1=new Label("First Name:",Label.LEFT); Label l2=new Label("Last Name:",Label.LEFT); Label l3=new Label("Gender(M/F):",Label.LEFT); Label l4=new Label("Branch:",Label.LEFT); Button b1=new Button("submit"); TextField t1=new TextField(); TextField t2=new TextField(); Choice c1=new Choice(); CheckboxGroup cbg=new CheckboxGroup(); Checkbox ck1=new Checkbox("Male",false,cbg); Checkbox ck2=new Checkbox("Female",false,cbg); Choice Branch=new Choice(); public student() { addWindowListener(new myWindowAdapter()); setBackground(Color.cyan); setForeground(Color.black); setLayout(null); add(l11); add(l1); add(l2); add(l3); add(l4); add(t1); add(t2); add(ck1); add(ck2); add(Branch); add(b1); b1.addActionListener(this); add(b1); Branch.add("c.s"); Branch.add("ece"); Branch.add("me"); l11.setBounds(10,40,280,20); l1.setBounds(25,65,90,20); l2.setBounds(25,90,90,20); l3.setBounds(25,120,90,20); l4.setBounds(25,185,90,20);

t1.setBounds(120,65,170,20); t2.setBounds(120,90,170,20); ck1.setBounds(120,120,50,20); ck2.setBounds(170,120,60,20); Branch.setBounds(120,185,170,60); b1.setBounds(120,350,50,30); } public void paint(Graphics g) {

g.drawString(msg,200,450);} public void actionPerformed(ActionEvent ae) { if(ae.getActionCommand().equals("save")) { setForeground(Color.red); } } public static void main(String args[]) { student stu=new student(); stu.setSize(new Dimension(400,400)); stu.setTitle("student registration"); stu.setVisible(true); } } class myWindowAdapter extends WindowAdapter {public void windowClosing(WindowEvent we) { System.exit(0); } }

You might also like