Question: Part 2: Using the JFrame Class In this section, you will add some code to your main method that creates an empty window on the
Part 2: Using the JFrame Class
In this section, you will add some code to your main method that creates an empty window on the screen. Locate the JFrame class in the Java API documentation. Then follow these steps to use that class in your program.
1.Add the required statement to the top of your class.
2.In your method, create a variable of type object. Then, assign a new object to that variable. Use the constructor that will allow you to set the window title to ?
3.Next, you need to instruct the that it is to be visible on the screen.
a.The method for doing this has been inherited by from another class. Find this method and use it in your code to make the visible.
b.Add a comment above that line of code to indicate which class the method was inherited from.
4.Now we need to set the size (width and height) of the window.
a.Locate the required method. (It has also been inherited.)
b.To call this method, you will need an instance of the class.
i.Add a new import statement to your code so that you have access to the class
ii.Then create a variable and assign it a new that is 300x300
c.Use the object you created to set the size of your window. Be sure to import any Java packages that you need to utilize this object.
5.Finally, we want the program to exit when the user clicks the red close button on the top-left corner of the window frame. has a particular method for specifying this behavior. Locate and use this method on your window to get the desired behavior. Hint: You will need to pass in a particular value that has been declared in the class. Access the value via that class like so, THE_VALUE.
here you can find lab materials :
https://www.dropbox.com/s/mo4y2p61bawof4o/lab11%202.zip?dl=0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
