Question

In: Computer Science

Write a class Twins that displays two identically sized windows, 200 * 100 each. The title...

Write a class Twins that displays two identically sized windows, 200 * 100 each. The title bar of the first window is labelled “Australia” and the second window is labelled “Melbourne”

Java Programming language

Solutions

Expert Solution

Name the Java file as Twins.java

Code for the Java file Twins.java is as follows:

import java.awt.*;
import javax.swing.*; 


public class Twins {
    private static void createWindow(String p) {
        //Create and set up the window. 
        JFrame frame = new JFrame(p);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // set the jframe size and location, and make it visible
        frame.setPreferredSize(new Dimension(200, 100));
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);

    }
     public static void main(String[] args){
        createWindow("Australia");
        createWindow("Melbourne");
    } 

    
}

Output:

Since the window is small (200*100), the entire names Australia and Melbourne in the window titles are not visible properly

I am providing extended windows of the same above screenshot in which the entire names Australia and Melbourne are visible in the window titles just for your reference

Hope this answers your questions, please leave a upvote if you find this helpful.


Related Solutions

Java Write a program that displays all the numbers from 100 to 200 that are divisible...
Java Write a program that displays all the numbers from 100 to 200 that are divisible by 5 or 6, but not both Make sure all instructions and outputs for the user are explicit
There are 35 identically sized balls in a box, where 5 of each of the colors...
There are 35 identically sized balls in a box, where 5 of each of the colors are present: red, orange, yellow, green, blue, indigo, and violet. Justify your answer for each. a. Suppose you draw a sample of seven balls without replacement from the box. What is the probability that the sample contains balls of exactly two colors? (for example, the event for which you have 4 red and 3 blue would satisfy) b. Suppose you draw a sample of...
(Use the GenericStack class) Write a program that displays the first 100 prime numbers in descending...
(Use the GenericStack class) Write a program that displays the first 100 prime numbers in descending order. Use a stack to store the prime numbers.
Write a program that displays a single character at 100 random screen locations, using a timing...
Write a program that displays a single character at 100 random screen locations, using a timing delay of 100 milliseconds. Hint: Use the GetMaxXY procedure to determine the current size of the console window. How to code this program with a defined character 'A' (I do not want to write a character to get a single character in the output console)
Two identical twins hold on to a rope, one at each end, on a smooth, frictionless...
Two identical twins hold on to a rope, one at each end, on a smooth, frictionless ice surface. They skate in a circle about the center of the rope (the center of mass of the two-body system) and perpendicular to the ice. The mass of each twin is 78.0 kg. The rope of negligible mass is 4.0 m long and they move at a speed of 4.90 m/s. (a) What is the magnitude, in kg · m2/s, of the angular...
Using python Write a program that displays all of states in the U.S. and display each...
Using python Write a program that displays all of states in the U.S. and display each state that begins with the letter A.
Write a program that displays all the cars in the given file (no sorting). Each car...
Write a program that displays all the cars in the given file (no sorting). Each car property is separated by a tab character: \t Given file: cars.txt make model year Ford Expedition 2003 Mazda B-Series 1989 Ford Freestar 2003 Hyundai Elantra 2001 Hyundai Entourage 2008 Chevrolet Camaro 2011 Chevrolet Monte Carlo 2006 Chevrolet Blazer 1996 Chevrolet Aveo 2005 Chevrolet Corvette 1999 Mercedes-Benz E-Class 2006 Dodge Avenger 1995 Pontiac Grand Prix 1973 Mitsubishi Outlander 2011 MINI Clubman 2011 Suzuki Aerio 2007...
An investment will pay $100 at the end of each of the next 3years, $200...
An investment will pay $100 at the end of each of the next 3 years, $200 at the end of Year 4, $300 at the end of Year 5, and $500 at the end of Year 6. If other investments of equal risk earn 6% annually, what its future value? Do not round intermediate calculations. Round your answers to the nearest cent.
Investment will pay $100 at the end of each of the next 3 years 200 at...
Investment will pay $100 at the end of each of the next 3 years 200 at the end of year 4 350 at the end of yearr 5 and 550 at the end of year 6 if other investments of equal risk earn 4% annually what is its present value Round your answer to the nearest cents.
Two payment plans are considered. Plan A pays $100 immediately, $200 in 2 years and $100...
Two payment plans are considered. Plan A pays $100 immediately, $200 in 2 years and $100 in 3 years. Plan B simply pays $350 immediately. (a) Compare the present values of Plan A and Plan B at 7.8% and 8.5% effective interest rate per year. (b) Assume Plan A is purchased for $350 at the time of the first payment. Prove the existence of a unique yield rate which lies between 7.8% and 8.5%. (c) Using a single iteration of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT