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.
Write a C function that finds and displays the maximum value ina two-dimensional array of...
Write a C function that finds and displays the maximum value in a two-dimensional array of integers. The array should be declared as a 10-row-by-20-column array of integers in main (), and the starting the address of the array should be passed to the function. Modify the function so that it also displays the rows and columns number of the element with the maximum value
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT