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

Document

This document defines a Java class called EventDriven_ALVEZ that creates a GUI with input and output frames. The input frame contains labels and text fields to collect a user's name, phone number, and email. Button clicks submit this data to labels in the output frame or clear all fields. The class implements an action listener to handle button clicks and transfer data between the frames.

Uploaded by

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

Document

This document defines a Java class called EventDriven_ALVEZ that creates a GUI with input and output frames. The input frame contains labels and text fields to collect a user's name, phone number, and email. Button clicks submit this data to labels in the output frame or clear all fields. The class implements an action listener to handle button clicks and transfer data between the frames.

Uploaded by

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

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package eventdriven_alvez;

import java.awt.*;

import javax.swing.*;

import javax.Swing.*;

import java.awt.event.*;

import java.text.*;

/**

* @author WS01-LAB1

*/

public class EventDriven_ALVEZ extends JFrame implements ActionListener {

JFrame m = new JFrame("OUTPUT");

JButton b1, b2, b3;

JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10;

JTextField t1, t2, t3 ,t4,t5;

EventDriven_ALVEZ(){
setLayout(new GridLayout(15,15));

setTitle("INPUT");

setSize(100, 100);

add(l1 = new JLabel("First Name: ",SwingConstants.CENTER));

add(t1 = new JTextField(20));

add(l2 = new JLabel("Last Name: ",SwingConstants.CENTER));

add(t2 = new JTextField(20));

add(l3 = new JLabel("Middle Name: ",SwingConstants.CENTER));

add(t3 = new JTextField(20));

add(l4 = new JLabel("Mobile Number: ",SwingConstants.CENTER));

add(t4 = new JTextField(20));

add(l5 = new JLabel("Email Address: ",SwingConstants.CENTER));

add(t5 = new JTextField(20));

add(b1 = new JButton("Submit"));

add(b2 = new JButton("Clear All"));

b1.addActionListener(this);

b2.addActionListener(this);

pack();

show();
}

@Override

public void actionPerformed(ActionEvent e) {

if(e.getSource() == b1){

b1.setEnabled(false);

m.setLayout(new GridLayout(10,10));

m.setVisible(true);

m.setSize(500,250);

String one = t1.getText();

String two = t2.getText();

String three = t3.getText();

String four = t4.getText();

String five = t5.getText();

String a = "First Name: " + " " + one;

String b = "Last Name: " + " " + two;

String c = "Middle Name: " + " " + three;

String d = "Mobile Number: " + " " + four;

String f = "Email Add: " + " " + five;

m.add(l6 = new JLabel(a));

m.add(l7 = new JLabel(b));

m.add(l8 = new JLabel(c));

m.add(l9 = new JLabel(d));

m.add(l10 = new JLabel(f));

m.add(b3 = new JButton("Okay"));

b3.addActionListener(this);
}

else if(e.getSource() == b2){

t1.setText("");

t2.setText("");

t3.setText("");

t4.setText("");

t5.setText("");

else if(e.getSource() == b3)

m.setVisible(false);

b1.setEnabled(true);

}
public static void main(String[] args) {

EventDriven_ALVEZ n = new EventDriven_ALVEZ();

n.addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e)

System.exit(0);

});

You might also like