Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Beginning with the file that you downloaded named Proj 0 7 . java, make a new file named Proj 0 7 Runner.java to meet the

Beginning with the file that you downloaded named Proj07.java, make a new file named Proj07Runner.java to meet the specifications given below.
Note that you must not modify the code in the file named Proj07.java. Make sure that you understand the comments and the code in that file.
Be sure to display your name in both locations in the output as indicated.
When you place both files in the same folder, compile them both, and run the file named Proj07.java, the program must display the text shown below on the command line screen. Note however that the border widths may vary from one system to the next. The border widths are being displayed to help you understand the coordinate values on your system.
When run it should display the following:
I certify that this program is my own work
and is not the work of others. I agree not
to share my solution with others.
Print your name here.
The JFrame width =300
The JFrame height =100
JFrame insets
30,7,7,7
The JPanel width =286
The JPanel height =63
JPanel insets
0,0,0,0
Also:
In addition, your program must display a single 300-pixel by 100-pixel JFrame object that displays your name on the topt as shown in the images below.
When you click the mouse in the working area of the JFrame, the coordinates of the mouse pointer must be shown in black above the mouse pointer and old coordinates must be erased. (Multiple images are shown below to show the result of clicking at different locations in the working area of the JFrame.)
Note that the 0,0 coordinate location is at the upper-left corner of the JPanel object, which covers the working area of the JFrame object.
As further clarification, when you click with the mouse pointer very close to the border on the left, the program must display a small horizontal (x) coordinate value. You should be able to display a horizontal coordinate value of 0,1, or 2 pixels, depending on your ability to accurately place the mouse pointer when you click.
The coordinate value must be displayed above and to the right of the mouse pointer. The tip of the mouse pointer must be at the bottom-left corner of the first text character.
When you click just far enough below the top banner to be able to read the text, the program must display a vertical (y) coordinate value approximately equal to the height of the text, 9,10, or 11 pixels for example.
When you click as close as possible to the bottom border, the program must display a vertical (y) coordinate value approximately equal to the JPanel height.
When you click close to the border on the right, most and perhaps all of the text will not be visible.
When you click the X-button in the upper-right corner of the JFrame object, the program must terminate and MUST RETURN CONTROL TO THE OPERATING SYSTEM.
IMPORTANT UPDATE: The zip file from which you extracted this document has been updated to contain all of the class files for my version of the program. Before you submit your assignment, please run your code side-by-side with my code and confirm that the behavior of your version matches the behavior of my version. By match I mean they show the same coordinate values, same text font, same text size, etc. for the same types of events. Pay particular attention to the coordinate values in the upper-left corner of the window. You may need to use the drawString method to cause your text to match my text. If you have issues running my code, please let me know. That would probably be the result of a Java version issue and I will help you work through it.
Proj07.java
/*File Proj07.java
The purpose of this assignment is to assess the student's
ability to write a Swing program handling mouse events on
a JFrame object containing a JPanel object.
**********************************************************/
import javax.swing.*;
import java.awt.*;
public class Proj07{
public static void main(String[] args){
Proj07Runner theRunner = new Proj07Runner();
JFrame theJFrame = theRunner.getJFrame();
System.out.println(
"The JFrame width ="+ theJFrame.getWidth());
System.out.println(
"The JFrame height ="+ theJFrame.getHeight());
Insets JFrameInsets = theJFrame.getInsets();
System.out.println("JFrame insets");
System.out.println(
JFrameInsets.top +","+JFrameInsets.left +","+
JFrameInsets.right +","+ JFrameInsets.bottom);
JPanel theJPanel = theRunner.getJPanel();
System.out.println(
"The JPanel width ="+ theJPanel.getWidth());
System.out.println(
"The JPanel height ="+ theJPanel.getHeight());
Insets JPanelInsets = theJPanel.getInsets();
System.out.println("JPanel insets");
System.out.println(
JPanelInsets.top +","+JPanelInsets.left +","+
JPanelInsets.right +","+ JPanelInsets.bottom);
}//end main
}//end class Proj07
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

ISBN: 1801072248, 978-1801072243

More Books

Students also viewed these Databases questions