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

Event Driven

ktjkgfjfgkgdh;csasjgs[ogsns aghahhahg

Uploaded by

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

Event Driven

ktjkgfjfgkgdh;csasjgs[ogsns aghahhahg

Uploaded by

chiancarloj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

NAME: CHIAN CARLO J.

YU SECTION:BT301A

import [Link].*;

import [Link].*;

import [Link].*;

public class EventDriven extends JFrame {

private JTextField tfFirstName, tfLastName, tfMiddleName, tfMobile, tfEmail;

private JButton btnSubmit, btnClearAll;

private JFrame outputFrame;

private JTextArea taOutput;

public EventDriven() {

// Initialize text fields

tfFirstName = new JTextField(15);

tfLastName = new JTextField(15);

tfMiddleName = new JTextField(15);

tfMobile = new JTextField(15);

tfEmail = new JTextField(15);

// Set up the main frame

[Link]("INPUT");

[Link](200, 200);

[Link](230, 310);

[Link](EXIT_ON_CLOSE);

[Link](new FlowLayout());

// Center the text within each JTextField


[Link]([Link]);

[Link]([Link]);

[Link]([Link]);

[Link]([Link]);

[Link]([Link]);

// Initialize buttons

btnSubmit = new JButton("Submit");

btnClearAll = new JButton("Clear All");

// Add components to the frame

add(new JLabel("First Name:"));

add(tfFirstName);

add(new JLabel("Last Name:"));

add(tfLastName);

add(new JLabel("Middle Name:"));

add(tfMiddleName);

add(new JLabel("Mobile Number:"));

add(tfMobile);

add(new JLabel("E-mail Address:"));

add(tfEmail);

add(btnSubmit);

add(btnClearAll);

// Add action listeners

[Link](new btnSubmit());

[Link](new btnClearAll());

setVisible(true);
}

class btnSubmit implements ActionListener {

public void actionPerformed(ActionEvent e) {

outputFrame = new JFrame("OUTPUT");

[Link](300, 200);

[Link](new FlowLayout());

taOutput = new JTextArea(5, 25);

[Link](false);

[Link]("First Name: " + [Link]() + "\n" +

"Last Name: " + [Link]() + "\n" +

"Middle Name: " + [Link]() + "\n" +

"Mobile Number: " + [Link]() + "\n" +

"E-mail Address: " + [Link]());

JButton btnOkay = new JButton("Okay");

[Link](new btnOkay());

[Link](taOutput);

[Link](btnOkay);

[Link](true);

[Link](false);

class btnClearAll implements ActionListener {

public void actionPerformed(ActionEvent e) {

// Clear text fields


[Link]("");

[Link]("");

[Link]("");

[Link]("");

[Link]("");

// Close output frame if it exists

if (outputFrame != null) {

[Link]();

[Link](true);

class btnOkay implements ActionListener {

public void actionPerformed(ActionEvent e) {

[Link]();

btnClearAll action = new btnClearAll();

[Link](null);

public static void main(String[] args) {

new EventDriven();

You might also like