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

  • Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the...

    Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the motion of an object projected into the air at an angle. The object flies in the air until the projectile returns to the horizontal axis (x-axis), where y=0. This MATLAB program should allow the user to try to hit a 2-m diameter target on the x-axis (y=0) by varying conditions, including the lunch direction, the speed of the lunch, the projectile’s size, and the...

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

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

  • C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) L...

    C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

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