Question

In JavaFX

Create a GUI program shown below. User enters information through the first window. When “Close” button is clicked, your prog

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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:
In JavaFX Create a GUI program shown below. User enters information through the first window. When...
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....

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

  • for Javascript, JQuery When the page is first opened a user will see the name field...

    for Javascript, JQuery When the page is first opened a user will see the name field and the three vacation images to the left of the page. The page should behave according to the following rules. 1. When a user's mouse pointer goes over any image, that image's border will change to be "outset 10px" and when the mouse pointer leaves that image it's border will change to "none". 2. When the user clicks a "Vacation" image on the left,...

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

  • This is just part of a C# windows form Application. When the user enters their information, checks the check box to save info and hits the payment button the information is saved to a .txt file. When...

    This is just part of a C# windows form Application. When the user enters their information, checks the check box to save info and hits the payment button the information is saved to a .txt file. When user enters last name and clicks autofill if name is found in file it will auto fill the boxes but i'm having issues with this part. For some reason it skips the firstname box and enters the last name in the first name...

  • Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class...

    Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class header instance variable UML class diagram encapsulation client visibility (or access) modifier accessor method mutator method calling method method declaration method invocation return statement parameters constructor Goals By the end of this activity you should be able to do the following: > Create a class with methods that accept parameters and return a value Understand the constructor and the toString method of a class...

  • Serendipity Engineering, Inc. Software Development Project Program Specifications: Serendipity Engineering, Inc. is a small engineering company...

    Serendipity Engineering, Inc. Software Development Project Program Specifications: Serendipity Engineering, Inc. is a small engineering company located in a commercial park. The project manager wants you to develop a customer software package that will allow the company enter the customer information in the computer to keep a customer database. The software will perform the following tasks using menus: Enter Customer Information Display Customer Information Search Customer Information Organize (Sort) Customer Information Add, Delete, Modify, and Look Up Customer Records Save...

  • Please Read it all and carefully In visual basic(vba)do the following program Summary INGE Industry, Inc....

    Please Read it all and carefully In visual basic(vba)do the following program Summary INGE Industry, Inc. needs a program in which the date and temperature in Celsius degrees of an industry laboratory are recorded and stored in a sequential file. In addition, you can see the recorded data and convert the temperatures in the following units: Fahrenheit, Kelvin and Rankine. In addition, they want to see a linear graph that reflects how the temperature has fluctuated day by day, for...

  • In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program...

    In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...

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