1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
steposvetlana [31]
3 years ago
9

Please design a Java GUI application with two JTextField for user to enter the first name and last name. Add two JButtons with a

ction events so when user click on one button to generate a full name message from the user input and put it in a third JTextField which is not editable; and click on the other button to clear all three JTextField boxes. Please run the attached nameFrame.class file (Note: because there is an actionhandler inner class in this program, another class file nameFrame$actionhandler.class was generated when you compile the .java file, you need both files in the same directory in order to run) to see the sample output. You need to design your program with a similar look and have your name as the author in a JLabel.

Computers and Technology
1 answer:
Ede4ka [16]3 years ago
5 0

Answer:

Check the explanation

Explanation:

Code :

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class nameFrame {

private JFrame mainFrame;

public nameFrame(){

prepareGUI();

}

public static void main(String[] args){

nameFrame nameFrame = new nameFrame();

}

private void prepareGUI(){

mainFrame = new JFrame("Name Frame");

mainFrame.setSize(450,250);

mainFrame.setLayout(new GridLayout(5, 2));

 

mainFrame.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent windowEvent){

System.exit(0);

}

});  

JLabel fname= new JLabel("First Name : ");

JLabel lname = new JLabel("Last Name : ");

JLabel fullname = new JLabel("Full Name : ");

JTextField fnameText = new JTextField(15);

JTextField lnameText = new JTextField(15);

JTextField fullnameText = new JTextField(30);

fullnameText.setEditable(false);

JButton submit = new JButton("submit");

submit.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {  

String data = fnameText.getText() + " " + lnameText.getText();

fullnameText.setText(data);

}

});

JButton clear = new JButton("clear");

clear.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {  

fnameText.setText("");

lnameText.setText("");

fullnameText.setText("");

}

});

mainFrame.add(fname);

mainFrame.add(fnameText);

mainFrame.add(lname);  

mainFrame.add(lnameText);

mainFrame.add(fullname);  

mainFrame.add(fullnameText);

mainFrame.add(submit);

mainFrame.add(clear);

mainFrame.setVisible(true);

}

}

Kindly check the attached output image below.

You might be interested in
Which of the following definition below describes a wall opening?
My name is Ann [436]
A. An opening at least 30 inches high and 18 inches wide in any wall or partition. 
5 0
3 years ago
Read 2 more answers
A telephone repair technician uses a meter to measure voltage on a phone line. This meter is an example of _____.
frozen [14]
It is an example of hardware.
3 0
3 years ago
Read 2 more answers
In GIMP, the ( ) displays the image that the user is currently working on
kotykmax [81]
I don'r know what your trying to use? GIMP is a free photo editing software just upload it to photobucket.
7 0
3 years ago
How many times will the loop body execute:
Xelga [282]
I’d also say B, which is 2
6 0
3 years ago
Define the computer with its workintg principple
GenaCL600 [577]

Explanation:

Computer is an electronic device that is designed to work with information.

WORKING PRINCIPLE OF COMPUTER

a.It accepts data and instructions by way of input,

b.It stores data,

c.It can process data as required by the user,

d.It gives result in the form of output,

e.It controls all operations inside a computer.

I hope it will help you

5 0
3 years ago
Other questions:
  • A (blank) is a way for students to keep track of information during research
    7·2 answers
  • Explain the role of the domain name system
    15·1 answer
  • • Describe the steps in detail that the operating system performs to handle interrupts, including ISRs, the stack, and hardware?
    5·1 answer
  • Identify the most appropriate way to display the following research data.
    12·1 answer
  • A hard drive cannot be partitioned until the device _________ is set.
    15·1 answer
  • Consider an application that transmits data at a steady rate (for example, the sender generates N-bit unit of data every k time
    7·1 answer
  • When using color in a computer - generated presentation aids you should use?
    7·1 answer
  • Question # 1 Multiple Select Which of the following shows the assignment of a string to a variable? Select 3 options. answer = "
    7·2 answers
  • It is usually simple to delete old posts and online conversations if they make you look bad.
    5·1 answer
  • Fill in the blanks with the correct words.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!