Question
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 butt
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please comment if you have any doubts or if want any modifications. Below code provides the exact output with main method also for reference I have uploading the screenshots of the program.

Code:-

/// Test.java ///

import java.io.*;
import java.util.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class Test
{
   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);
   }
}

Code Screenshots:-

1 2 نیا import java.io.*; import java.util.*; import java.awt.event.*; import java.awt.*; import javax.swing.*; public classshow_info.addActionListener(new ActionListener() { 白中中 public void action Performed (ActionEvent e) { String a=t1.getText();frame2.add (agel); frame2.add(idl); JTextField til=new JTextField(); JTextField t21=new JTextField(); JTextField t31=new JTexclose.addActionListener(new ActionListener() { public void action Performed (ActionEvent e) { 로 frame. dispose(); 120 121 122

Output:-

Input - Х Name: Tom Age : תם ID: 123 Show Info Modify Close Name: Tom Age : 5 ID: 123

Result X Name: Tom Age: 5 ID: 123 Change

Result - X Name: Jerry Age : ID: 456 Change

Input - Х Name: Jerry Age : 6 ID: 456 Show Info Modify Close Name: Jerry Age: 6 ID: 456

Please UPVOTE thank you...!!!

Add a comment
Know the answer?
Add Answer to:
the program must contain the main method and example(s) must be included in the main method...
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 JAVA please please include a main() and show output!! Create a GUI program shown below....

    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....

  • 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...

  • in java the program must contain the main method and example( the number 50 should be...

    in java the program must contain the main method and example( the number 50 should be the input) must be included in the main method to check the correctness of your programs. Create a GUI program to let user enter a positive integer n through the first window, and then your program prints out all the prime integers within the range [1, n) through the second window. Your program should contain two windows in total. Below are two example pictures:...

  • ****THIS IS A 2 PART QUESTION! I ONLY NEED THE ANSWER TO PART 2 ON HOW...

    ****THIS IS A 2 PART QUESTION! I ONLY NEED THE ANSWER TO PART 2 ON HOW TO SEND THE DATA SERIALIZED**** Write a c# program that stores student grades in a text file and read grades from a text file.  The program has the following GUI: There are four buttons: Create File, Save Case, Close File and Load File.  Initially, only the Create File and Load File buttons are enabled.  If the user clicks the Create File button, a Save File Dialog window...

  • 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....

  • Write a complete JAVA program to do the following program. The main program calls a method...

    Write a complete JAVA program to do the following program. The main program calls a method to read in (from an input file) a set of people's three-digit ID numbers and their donations to a charity (hint: use parallel arrays)Then the main program calls a method to sort the ID numbers into numerical order, being sure to carry along the corresponding donations. The main program then calls a method to print the sorted 1ists in tabular form, giving both ID...

  • Need help!!! I need two programs that use one common database.. One program using a Visual...

    Need help!!! I need two programs that use one common database.. One program using a Visual Basic windows form using textboxes for data input (first name, last name, phone, email) and it should save the info into an SQL database when a save button is clicked. Second program using a C# windows form that has a drop down menu with all the names that have been saved into the database, when one name is clicked all their information should pop...

  • 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...

  • Write a html javascript program to do the following: the user inputs a number, for example,...

    Write a html javascript program to do the following: the user inputs a number, for example, 50 user presses a button, labeled START the program creates 50 random buttons around the browser window each button should be placed at a random location each button should be labeled with a random number between 1 and 50 add the following features every 2 seconds, move each button around by increment or decrementing its location if the user clicks on a button, change...

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