Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Saturday, 23 February 2019

Fifth Week Term Work Program 4


Question









Program:


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

public class Registrationform {
public static void main(String[] args) {
Frame f = new RegistrationFrame("Registration Form");
f.setSize(260, 200);
f.setVisible(true);
}
}
//Frame class
class RegistrationFrame extends Frame {
public RegistrationFrame(String title) {
super(title);
setLayout(null);
setBackground(Color.white);
Label l1=new Label("Enter your name:");
l1.setBounds(10, 40, 120, 50);
Label l2=new Label("Enter your Mobile no:");
l2.setBounds(10, 70, 120, 50);
add(l1);
add(l2);
TextField t1=new TextField();
t1.setEditable(true);
t1.setBounds(130, 55, 100, 20);
TextField t2=new TextField();
t2.setBounds(130, 85, 100, 20);
t2.setEditable(true);
add(t1);
add(t2);

//Add  button to frame 
Button b = new Button("Submit");
b.setBounds(30, 150, 100, 30);
add(b);

Button b1 = new Button("Clear");
b1.setBounds(140, 150, 100, 30);
add(b1);


//Attach window listener
addWindowListener(new WindowCloser());
}

//Listener for window
class WindowCloser extends WindowAdapter {
public void windowClosing(WindowEvent evt) {
System.exit(0);
}
}
}


0 comments:

Post a Comment