Files Lab2.java x + 1 /* Main.java 2 3 */ Lab2.java M+ README.md TestWindow.java Put your...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Files Lab2.java x + 1▾ /* Main.java 2 3 */ Lab2.java M+ README.md TestWindow.java Put your comments here 4 import javax.swing.*; 5 import java.awt.Color; 6 class Lab2 extends JFrame { 7▾ 8 9 public Lab2(String title) { super(title); setBounds(0,0,400,300); setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); public static void main(String[] args) { 10 11 } 12 ▼ 13 14 15 1"); 16 17 18 19 20 Lab2 myApp = new Lab2("Lab2"); myApp.setVisible(true); TestWindow wind1 = new TestWindow(myApp, "Window TestWindow wind2 = wind1; wind 2.setTitle("Window 2"); wind 2.setColor(Color.green); wind1.setVisible(true); wind2.setVisible(true); VNC Lab2 Window 2 Consolex Shell x + w/Lab2-KevinDoan7$ javac Lab2.java ~/Lab2-KevinDoan7$ java Lab2 CPU RAM Stora... 21 2 22} } 51. Go to Shell and run **javac Lab2.java** 6 2. Note that only one **TestWindow** object is created. Look at the code for Lab2.java to understand why. 7 3. Modify Lab2.java so that two **TestWindow** objects are created. Make use of the **setLocation()** to make it so that the two **TestWindow** objects don't overlap 8 ## Finishing up 9 - Add a block comment to Lab2.java that explains why the original Lab2.java code only produced on window on top of the main window. 10 - Within that same block comment, explain what you did to get the program to work correctly (i.e. two windows on top of the main window). Files Lab2.java x + 1▾ /* Main.java 2 3 */ Lab2.java M+ README.md TestWindow.java Put your comments here 4 import javax.swing.*; 5 import java.awt.Color; 6 class Lab2 extends JFrame { 7▾ 8 9 public Lab2(String title) { super(title); setBounds(0,0,400,300); setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); public static void main(String[] args) { 10 11 } 12 ▼ 13 14 15 1"); 16 17 18 19 20 Lab2 myApp = new Lab2("Lab2"); myApp.setVisible(true); TestWindow wind1 = new TestWindow(myApp, "Window TestWindow wind2 = wind1; wind 2.setTitle("Window 2"); wind 2.setColor(Color.green); wind1.setVisible(true); wind2.setVisible(true); VNC Lab2 Window 2 Consolex Shell x + w/Lab2-KevinDoan7$ javac Lab2.java ~/Lab2-KevinDoan7$ java Lab2 CPU RAM Stora... 21 2 22} } 51. Go to Shell and run **javac Lab2.java** 6 2. Note that only one **TestWindow** object is created. Look at the code for Lab2.java to understand why. 7 3. Modify Lab2.java so that two **TestWindow** objects are created. Make use of the **setLocation()** to make it so that the two **TestWindow** objects don't overlap 8 ## Finishing up 9 - Add a block comment to Lab2.java that explains why the original Lab2.java code only produced on window on top of the main window. 10 - Within that same block comment, explain what you did to get the program to work correctly (i.e. two windows on top of the main window).
Expert Answer:
Answer rating: 100% (QA)
Heres the modified Lab2java file with comments explaining why only one window was initially created ... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
(10 points) Given that ry + xy = 1. 1. Find a solution of the differential equation that satisfies the initial condition y(1) = 10. Answer: y = 2. Find a solution of the differential equation that...
-
At the beginning of September, Selena Cantu started Cantu Wealth Management Consulting, a firm that offers financial planning and advice about investing and managing money. On September 30, the...
-
Explain relationships between implied and express warranties.
-
Marshall, age 17, was ejected from his parents home shortly after his graduation from high school. He then rented an apartment with Fletcher, a girlfriend. They signed a lease together, and Marshall...
-
Describe the functions of each of the four lobes of the cerebrum.
-
The budget for the Baldwin Equipment, Inc. job in P9-1 consisted of the following amounts: Partners salary and overhead . . . . . . . . . . . . . $6,300 Associates salary and overhead . . . . . . . ....
-
Describe the impact of social perception in the healthcare setting. Why is cross-cultural communication important to today's health services organizations? Compare and contrast content and process...
-
You have a 9 9 grid of squares, each of which can be colored red or blue. The grid is initially colored all blue, but you can change the color of any square any number of times. Imagining the grid...
-
According to Wendy Su, what are the three main phases in the history of Chinese martial arts cinema in the 20 th century? What is the new hybrid martial arts cinema of the 21 st century and how does...
-
Write a python function named compare that compares two fractions. The function should take two fractions (represented as tuples) as arguments and return an integer. If the first argument is smaller...
-
When a correcting entry includes a debit to Shop Equipment for $800 and a credit to Office Equipment for $800, what is the impact of this entry?
-
Marsha had earned income of $130,000 in 2013 and $150,000 in 2014. She contributed $18,000 to her RRSP in 2014 when the maximum was the lesser of 18% of 2013 earned income and the RRSP Contribution...
-
Your client bought 1,000 shares of ABC on margin that he believes will appreciate in value when earnings are released. He is leaving for a three-month vacation and wants to place an order that will...
-
Schmidt wishes to leave the partnership and will be paid $120,000. After the revaluation of the partnerships intereste, Tanner, Schimits and hayes the trhree aprtners, have capital account balances...
-
Our client, Mr. MerrilSimns, is being sued by Tom Kells for breach of an implied warranty of fitness for a particular purpose in the case of Kells v. Simns. Mr. Simns placed an ad in the Daily Post...
-
You have accepted the engagement of auditing the financial statements of the C. Reis Company, a small manufacturing firm that has been your auditee for several years. Because you were busy writing...
-
Write a program that displays a drawing for the popular hangman game, as shown in Figure 14.48a. (a)
-
? can be computed using the following series: Write a method that returns?m(i)?for a given?i?and write a test program that displays the following table:i .......................m(i)1...
-
Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, and computes the total and average of the input values (not counting...
-
In December, the first five transactions of Gillespie Consulting have been posted to the T-accounts. Prepare the journal entries that served as the sources for the five transactions. Include an...
-
Daniel Bronstein practices medicine under the business title Daniel Bronstein, M.D. During July, the medical practice completed the following transactions: The business uses the following accounts:...
-
Michael Rose opened a law office on April 1, 2025. During the first month of operations, the business completed the following transactions: Requirements 1. Record each transaction in the journal,...
Study smarter with the SolutionInn App