Question
in JAVA please please include a main() and show output!!

Create a GUI program shown below. User enters information through the first window. When “Close” button is clicked, your program stops; when “Show Info” button is clicked, the input information is displayed on the TextArea; while when “Modify” button is clicked, the second window pops up and the information user enters to the first window automatically fills in the second window. User can change the information on the second window. After clicking the “Change” button on the second window, the second window disappears, and the new information user enters to the second window automatically fills in the first window and the TextArea also changes correspondingly.

0 X Result ох Input Name Tom Name om Age 5 Age: Step 2 Step 1 ID: 123 ID: 123 Show Info Modify Close Change Name: Tom Age: 5
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

CODE: Java Programming Language

import java.io.*;
import java.util.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class GUI{
   // Main method
   public static void main(String[] args){
       JFrame frame=new JFrame("Input");
       frame.setSize(400,400);
       JLabel name=new JLabel("Name : ");
       JLabel age=new JLabel("Age : ");
       JLabel id=new JLabel("ID : ");
       name.setBounds(100,30,100,30);
       age.setBounds(100,80,100,30);
       id.setBounds(100,130,100,30);
       frame.add(name);
       frame.add(age);
       frame.add(id);
       JTextField t1=new JTextField();
       JTextField t2=new JTextField();
       JTextField t3=new JTextField();
       t1.setBounds(150,30,100,30);
       t2.setBounds(150,80,100,30);
       t3.setBounds(150,130,100,30);
       frame.add(t1);
       frame.add(t2);
       frame.add(t3);
       JButton show_info=new JButton("Show Info");
       JButton modify=new JButton("Modify");
       JButton close=new JButton("Close");
       show_info.setBounds(30,180,100,30);
       modify.setBounds(140,180,100,30);
       close.setBounds(250,180,100,30);
       frame.add(show_info);
       frame.add(modify);
       frame.add(close);
       JTextArea text_area=new JTextArea();
       text_area.setBounds(45,240,300,100);
       frame.add(text_area);     
       show_info.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
               String a=t1.getText();
               String b=t2.getText();
               String c=t3.getText();
               if(a.equals("") || b.equals("") || c.equals("")){
                   JOptionPane.showMessageDialog(frame,"Enter All Fields !!!","Warning",JOptionPane.WARNING_MESSAGE);
               }
               else{
                   String display="Name : "+a+"\n"+"Age : "+b+"\n"+"ID : "+c;
                   text_area.setText(display);
               }   
           }
       });
       modify.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
               String a=t1.getText();
               String b=t2.getText();
               String c=t3.getText();
               if(a.equals("") || b.equals("") || c.equals("")){
                   JOptionPane.showMessageDialog(frame,"Enter All Fields !!!","Warning",JOptionPane.WARNING_MESSAGE);
               }
               else{
                   JFrame frame2=new JFrame("Result");
                   frame2.setSize(400,300);
                   JLabel name1=new JLabel("Name : ");
                   JLabel age1=new JLabel("Age : ");
                   JLabel id1=new JLabel("ID : ");
                   name1.setBounds(100,30,100,30);
                   age1.setBounds(100,80,100,30);
                   id1.setBounds(100,130,100,30);
                   frame2.add(name1);
                   frame2.add(age1);
                   frame2.add(id1);
                   JTextField t11=new JTextField();
                   JTextField t21=new JTextField();
                   JTextField t31=new JTextField();
                   t11.setText(a);
                   t21.setText(b);
                   t31.setText(c);
                   t11.setBounds(150,30,100,30);
                   t21.setBounds(150,80,100,30);
                   t31.setBounds(150,130,100,30);
                   frame2.add(t11);
                   frame2.add(t21);
                   frame2.add(t31);
                   JButton change=new JButton("Change");
                   change.setBounds(140,180,100,30);
                   frame2.add(change);
                   change.addActionListener(new ActionListener() {
                       public void actionPerformed(ActionEvent e) {
                           String s1=t11.getText();
                           String s2=t21.getText();
                           String s3=t31.getText();
                           t1.setText(s1);
                           t2.setText(s2);
                           t3.setText(s3);
                           String result="Name : "+s1+"\n"+"Age : "+s2+"\n"+"ID : "+s3;
                           text_area.setText("");
                           text_area.setText(result);
                           frame2.dispose();       
                       }
                   });
                   frame2.setLayout(null);
                   frame2.setVisible(true);
               }
           }
       });
       close.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
               frame.dispose();
           }
       });
       frame.setLayout(null);
       frame.setVisible(true);
   }
}

=========================================================================

SCREENSHOT OF THE CODE:

9 10 import java.io.*; 2 import java.util.*; 3 import java.awt.event.*; 4 import java.awt.*; 5 import javax.swing.*; 6 publicframe.add(close); JTextArea text_area=new JTextArea(); text_area.setBounds (45, 240,300,100); frame.add(text_area); show_info73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 900 A 910 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 fram1090 41100 111 112 113 114 115 116 117 } close.addActionListener(new ActionListener() { public void actionPerformed (ActionEv

=========================================================================

OUTPUT:

X Input Name: Tom Age : 01 ID : 123 Show Info Modify Close Name : Tom Age: 5 ID: 123Result х Name: Tom Age: 5 ID: 123 Change0 Result x Name: Jerry Age: 6 ID: 456 ChangeO X Input Name: Jerry Age: 6 ID: 456 Show Info Modify Close Name : Jerry Age: 6 ID: 456

Thank you

Add a comment
Know the answer?
Add Answer to:
in JAVA please please include a main() and show output!! Create a GUI program shown below....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In JavaFX Create a GUI program shown below. User enters information through the first window. When...

    In JavaFX Create a GUI program shown below. User enters information through the first window. When “Close” button is clicked, your program stops, when “Show Info” button is clicked, the input information is displayed on the TextArea; while when “Modify" button is clicked, the second window pops up and the information user enters to the first window automatically fills in the second window. User can change the information on the second window. After clicking the “Change” button on the second...

  • the program must contain the main method and example(s) must be included in the main method...

    the program must contain the main method and example(s) must be included in the main method to check the correctness of your programs. Problem 3/5 (30 points) Create a GUI program shown below. User enters information through the first window. When "Close" button is clicked, your program stops; when "Show Info” button is clicked, the input information is displayed on the TextArea; while when “Modify" button is clicked, the second window pops up and the information user enters to the...

  • In Java, please write the program for the following program. Please TEST YOUR PROGRAM. You MUST...

    In Java, please write the program for the following program. Please TEST YOUR PROGRAM. You MUST use GUI, that means all user input must be through the windows. The "first window" is the window on the top left of the following picture. Add 5 more items to be purchased. Search is accessed from second window, top right. Thw third window is the bottom left, and the fourth window is the bottom right. The program MUST CONTAIN EVERYTHING IN THE PICTURES....

  • in JAVA please and please show output!! Create a JavaFX application that simulates the rolling of...

    in JAVA please and please show output!! Create a JavaFX application that simulates the rolling of a pair of dice. When the user clicks a button, the application should generate two random numbers, each in the range of 1 through 6, to represent the value of the dice. Use ImageView component to display the dice. Six images are included in the project folder for you to use. For example, the first picture below is the initial window, after clicking the...

  • Consider the attached Registration form. Use jQuery to: 1) Change the "Search" link on the left...

    Consider the attached Registration form. Use jQuery to: 1) Change the "Search" link on the left to a button that when clicked, hide all the fields on the form and display the text "This is a search feature..." 2) Display "required" in every input field upon loading the page 3) When the user fills the form and clicks "Login", the values inputted should be displayed in the empty row (under Login) of the page. The display should be in the...

  • Can someone help fix this JAVASCRIPT code according to comment instructions javascriot code: window.addEventListener("click", () =>...

    Can someone help fix this JAVASCRIPT code according to comment instructions javascriot code: window.addEventListener("click", () => { console.log("You clicked?"); }); let button = document.querySelector("button"); button.addEventListener("click", () => { console.log("First Button clicked."); }); // How can we modify this so that it will occur when the 2nd button is clicked? // We need to use querySelectorAll which will produce a nodelist/array of all the buttons. Then we can reference which button we want to apply the click event using [] with...

  • given below are the project description and their Html and css files i need javascript according to the project and other files!

    HTML------------------------------------------------------CSS---------------------------------------------------WEB230 - JavaScript 1 Assignment 7 - FormsSome of these tasks would be better done in HTML or CSS but do them in JavaScript to practice whatwe have learned.1. Select the form element and save it in a variable. From here we can access all of the form fields.2. When the page loads do the following:add the password value "monkey"select the favourite city "New York"clear the textarea3. Add an event handler to the "name" field to change the background color...

  • ***PLEASE AVOID USING A "CLASS" IN SOLUTION*** thank you. Please use Visual Studio to write a...

    ***PLEASE AVOID USING A "CLASS" IN SOLUTION*** thank you. Please use Visual Studio to write a C# program to allow user to store contact information. 1. User should be able to type in name, E-mail and phone number in the text boxes and click Add button to save the contact record. Every time when user add record, user should be able to see all the information displayed in the right side display text box. (allow up to 10 records) 2....

  • Please include comments in java Create a command line program that can be used for computer...

    Please include comments in java Create a command line program that can be used for computer inventory purposes Create a super class that will store the following data: CPU speed Amount of RAM Hard Disk size Operating System Allow the user to enter data using any units of measurement they desire (i.e. - 500GB or 1TB for hard disk size). Create a class that inherits from the previous class and stores information for a Windows based computer. Store the following...

  • Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by...

    Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by implementing Person and Student classes. Once you are sure you can serialize and deserialize and ArrayList of Students to and from a file, move on to building the GUI application. Person: The Person class should implement serializable interface. It contains the following: Person's first name (String) Person's last name (String) Person's id number Person's date of birth (Date) public String toString(): This method method...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT