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
The picture that graphically represents the items you use in Windows is called a/an GUI
egoroff_w [7]

That's a TLA for "<em><u>Graphical User Interface</u></em>".


8 0
4 years ago
Read 2 more answers
PLEASE I NEED HELP FAST
tankabanditka [31]

Answer:

your answer will be src=

7 0
3 years ago
¿Qué podría pasar si los avances tecnológicos cayeran en personas sin formación Ética-Moral?
timurjin [86]

Answer:

If technological advances fall on people without Ethical-Moral training, then life itself would be threatened as our humanity and environment would be destroyed.

Explanation:

Question:

What could happen if technological advances fell on people without Ethical-Moral training?

Morals: Morals refer to human behavior. The principles of right and wrong

Ethics: It is the body of rules and regulations that dictate the conduct of practitioners of a particular profession.

In terms of technology, ethics is viewed in two contexts; if the pace of technological innovation is benefiting the humanity or not; if it is severely empowering people while choking others in the process.

Technology: it is the application of scientific principles for practical purposes of human life. Technology when used properly improves the quality of life of people.

On one hand, technology in itself is said to be neither good nor bad. It is people who determine it's application. With this said, we can infer that if technology falls on the wrong hands, it could be disastrous.

On the other, some technologies like nuclear fission, genetic engineering exert enormous power that their existence raises ethical or moral questions.

The role of ethical training in technological advancement would be to monitor rather than control to ensure fair practices.

Now if technological advances fell on people without ethical-moral training, then life itself would be threatened:

- Cultural breakdown: Almost everything in our day to day lives would depend on technology

- Loss of jobs: this would happen when machines do the work of men

- Inequalities as those with initial access to it would be the rich thereby widening the gap between the rich and poor.

- Exploitation as competition towards Mastery and control increases

- Environmental degradation

5 0
3 years ago
"Using the printf method, print the values of the integer variables bottles and cans so that the output looks like this: Bottles
Anika [276]

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       

       System.out.println("Enter the number of bottles and cans:");

       int numberOfbottles = in.nextInt();

       int numberOfcans = in.nextInt();

       System.out.printf("Bottles: %8d\n", numberOfbottles);

       System.out.printf("Cans:    %8d\n", numberOfcans);

}

}

Explanation:

Ask user to input the number of bottles and cans using Scanner class

Print the results so that the numbers to the right line up (Since we know that the numbers have at most 8 digits, we can use %8d in printf. Also, be aware that how printf statements are written so that the numbers line up)

6 0
3 years ago
Select the two true statements about functions with parameters:
kondor19780726 [428]

Answer:

Option (B) and (C) is the correct option to the following question.

Explanation:

Because the function is the module of the program and we call that function again and again anywhere whenever we need that function in the program.

Function is used to carry out any operation which is used in the program many times and it creates the program short and simple.

<u>For example</u>: if we need to add or multiply two numbers many times in the program then, we create one or two functions for addition and subtraction or one program for both, when we need them we call them.

4 0
3 years ago
Other questions:
  • If you feel that an OSHA inspection is needed to get hazards corrected at your workplace which is the best option
    9·1 answer
  • 1. If you are 15% years old, you are old enough to obtain
    10·2 answers
  • What can help prevent issues related to downloading content from the internet
    11·2 answers
  • When activated, an Excel object has all the features of an Excel
    8·2 answers
  • A virus that is embedded in the automatically executing scipts commonly found in word processors, spreadsheets, and database app
    13·2 answers
  • My Mac is stuck on this screen? How to fix?
    10·1 answer
  • There are two circular grounds Ground-A and Ground-B. Ground-A is having diameter of 15 meters and Ground-B is having diameter o
    7·1 answer
  • ¡Hola! He visto en muchos comentarios de Twitter "svd" cuando alguien dice "dale fav a este Tweet y siganse entre ustedes" y en
    8·1 answer
  • Layers allow you to work with one element of an image without disturbing the others true or false​
    15·1 answer
  • It is important to consider the quality of the data being used when considering the accuracy of a conclusion. Incorrectly collec
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!