Question

Write a Java program that constructs a window having the title "The Hello Application - Ver....

Write a Java program that constructs a window having the title "The Hello Application - Ver. 1.0" . Make sure that your program contains a window closing event object that correctly closes the window when the Close (X) button is clicked

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

package myfirstguiapplication;
import java.awt.*;
import java.awt.event.*;

public class MyFirstGUIApplication extends WindowAdapter//extending window adapter
{
    Frame frame;        //creating a new frame variable
    MyFirstGUIApplication()
    {
        frame=new Frame("The Hello Application - Ver. 1.0");//defining a new frame with name "The Hello Application - Ver. 1.0"
        frame.addWindowListener(this);      //
        frame.setSize(500,200);             //setting size of window to be 500*200
        frame.setLayout(null);              //setting any layouts to null
        frame.setVisible(true);             //making frame visible
    }
    @Override
    public void windowClosing(WindowEvent e) //creating a new window event class object
    {
        frame.dispose(); //disposes the frame
    }
    public static void main(String[] args)
    {
        new MyFirstGUIApplication();//calling the constructer
    }
}

OUTPUT:
The Hello Application - Ver. 1.0 - 0 x

Ask any doubt if you have in comment section below.

Please leave a rating

Add a comment
Know the answer?
Add Answer to:
Write a Java program that constructs a window having the title "The Hello Application - Ver....
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
  • Write a program in Java (using swing) that opens a window that contains a button. The...

    Write a program in Java (using swing) that opens a window that contains a button. The button is labled with "0" (zero). With every click on the button, the number in its label increments by 1.

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

  • JAVA SOLUTION This lab has four parts: Create a window. Create 5 buttons in that window....

    JAVA SOLUTION This lab has four parts: Create a window. Create 5 buttons in that window. Create an event when a button is pushed. Create an event listener that will respond to the button being pushed event. Task 1 – Create a Window For Java: Please ensure that the following import statements are used: import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.GridPane; import javafx.scene.text.Text; import javafx.event.EventHandler; import javafx.scene.input.MouseEvent; Next, ensure that there is a main method which is...

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

  • Write a program in Java that converts the following do-while loop block to: for loop Write,...

    Write a program in Java that converts the following do-while loop block to: for loop Write, compile and run below program segment. Make sure to click on the Output Window to input the number. Evaluate the program. Take notes and comment of below program segments of your observations. int x; Scanner input = new Scanner(System.in);       x = input.nextInt();       do{             System.out.printf(“%d\n”, x * 2);             x++;       } while(x < 100);

  • Write a program in Java that computes the number of words in a text entered in...

    Write a program in Java that computes the number of words in a text entered in a text field. Use the following graphical objects: a text field for the input text (one line of text) a button that, when pressed, computes the word count a button that, when pressed, clears the text field labels for the input and output and for showing the word count Requirements and Restrictions: Choose proper background, color, and layout and arrange the graphical objects exactly...

  • -Write a JavaFX application that displays a Label containing the opening sentence or two from your...

    -Write a JavaFX application that displays a Label containing the opening sentence or two from your favorite book. Save the project as FXBookQuote1a. -Add a button to the frame in the FXBookQuote program. When the user clicks the button, display the title of the book that contains the quote in a second label. Save the project as FXBookQuote1b.

  • In Java. Write a GUI contact list application. The program should allow you to input names...

    In Java. Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...

  • Write a Java application program that plays a number guessing game with the user. In the...

    Write a Java application program that plays a number guessing game with the user. In the starter code that you are given to help you begin the project, you will find the following lines of code: Random generator = args.length == 0 ? new Random() :                    new Random(Integer.parseInt(args[0])); int secret = generator.nextInt(100); You must keep these lines of code in your program. If you delete these lines, or if you change thse lines in any way, then your program...

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