Exercise 3A [5%] Create a class called Letter2DDisplay. Extend this class from JComponent. Add a private...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Exercise 3A [5%] Create a class called Letter2DDisplay. Extend this class from JComponent. Add a private variable of type Letter2D []. If you have not completed Exercise 1 replace Letter2D[] with a 2D int array in all Exercises. Exercise 3B [5%] Add a constructor to the class that receives a Letter2D [] parameter. Initialise the variable you created in 3A with this parameter. Exercise 3C [15%] Override the paint Component method. In the method iterate over the Letter2D[] variable and draw the corresponding letter for each element at the coordinates stored in the Letter2D. If you are using the int[] [] choose a colour and radius randomly and draw a corresponding oval. Exercise 3D [15%] Create another class called MyMain with a main method. In this main method first write ten Letter2D (or int[] []) to a file, then read them again into a corresponding array. Create a JFrame with size 500 x 500 pixels and add a Letter2DDisplay object to it. Provide the array you just read to the Letter2DDisplay constructor. Make the JFrame visible. You can use the code for creating the JFrame and writing and reading using Letter2DIO below: Letter2DIO.writeRandom Letters ("test", 100); JFrame f = new JFrame("Letter2D Display"); f.setSize(500, 500); f.add(new Letter2DDisplay (Letter2DIO. readLetters ("test", 100))); f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); f.setVisible(true); Exercise 3A [5%] Create a class called Letter2DDisplay. Extend this class from JComponent. Add a private variable of type Letter2D []. If you have not completed Exercise 1 replace Letter2D[] with a 2D int array in all Exercises. Exercise 3B [5%] Add a constructor to the class that receives a Letter2D [] parameter. Initialise the variable you created in 3A with this parameter. Exercise 3C [15%] Override the paint Component method. In the method iterate over the Letter2D[] variable and draw the corresponding letter for each element at the coordinates stored in the Letter2D. If you are using the int[] [] choose a colour and radius randomly and draw a corresponding oval. Exercise 3D [15%] Create another class called MyMain with a main method. In this main method first write ten Letter2D (or int[] []) to a file, then read them again into a corresponding array. Create a JFrame with size 500 x 500 pixels and add a Letter2DDisplay object to it. Provide the array you just read to the Letter2DDisplay constructor. Make the JFrame visible. You can use the code for creating the JFrame and writing and reading using Letter2DIO below: Letter2DIO.writeRandom Letters ("test", 100); JFrame f = new JFrame("Letter2D Display"); f.setSize(500, 500); f.add(new Letter2DDisplay (Letter2DIO. readLetters ("test", 100))); f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); f.setVisible(true);
Expert Answer:
Answer rating: 100% (QA)
Heres a possible implementation of the exercises described import javaxswing import javaawt import j... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Pokmon GO continues to be one of the highest grossing mobilegames. In the game, you encounter wild pokemon, which you can attempt to catch. Each gamefor Pokemon uses slightly different rules for...
-
In December 2014, Shire Computer's management establishes the 2015 predetermined overhead rate based on direct labor cost. The information used in setting this rate includes estimates that the...
-
Highway curves are marked with a suggested speed. If this speed is based on what would be safe in wet weather, estimate the radius of curvature for an unbanked curve marked 50 km / h. Use Table 4-2...
-
For Exercises explain how each could be simulated by using random numbers. Two players select a card from a deck with no face cards. The player who gets the higher card wins.
-
Discuss the themes, theory, and/or phenomenon that would be anticipated to emerge as a result of the examination. Develop a hypothetical research scenario that would necessitate the use of the Action...
-
Lahey Corp. has three defined-benefit pension plans as follows. How will Lahey report these multiple plans in its financial statements? Plan X Plan Y Plan Z Pension Assets (at Fair Value) $600,000...
-
Compare and contrast DDL commands with DML commands. You are requested to submit one example of SQL query for DDL and one for DML
-
Arndt, Inc., reported the following for 2024 and 2025 ($ in millions): a. Expenses each year include $30 million from a two-year casualty insurance policy purchased in 2024 for $60 million. The cost...
-
1. Propose ONE new product or service that you should produce or develop for a new startup business through e-commerce web application. Give reasons and justify why you suggest that product. 2....
-
P8-14 Activity-Based Costing as an Alternative to Traditional Product Costing: Simplified Method This chapter emphasizes the use of activity-based costing in internal decisions. However, a modified...
-
A simple trust has one beneficiary and in the current year has interest income of 8,000.00, tax exempt interest of$6,000.00, c/g income of$4,000 and fiduciary fees expense of $2,000.00 (allocable to...
-
You are to select 5 companies for your investment portfolio. In order to get the best portfolio combination of companies for the purpose of diversifying the risk, you have to screen for best...
-
Once again consider the investment project from Question 7 where QAN is considering a project that requires an initial investment of $800m now, but that is expected to generate free cash flows of...
-
Evaluate the integral S dx 1 + sin(x)
-
A metal strip 6 cm long, 0.8 cm wide, and 0.7 mm thick moves with constant velocity v through a uniform magnetic field B = 1 mT perpendicular to the strip, as shown in the figure. A potential...
-
The Cholesterol Level data sets give cholesterol levels of heart attack patients. Cholesterol measures are taken 2, 4, and 14 days aft er a patient has suffered a heart attack. Is there a significant...
-
Imagine a program that compresses files by 80 percent and stores them on storage media. Before the compressed file is stored, it must be divided into blocks of 512 bytes each. Develop an algorithm...
-
Define named constants that you could use in Programming Project 6 in Chapter 1. Programming Project 6 Write an JavaFx application that displays the following pattern:
-
Create an application that will keep track of several groups of strings. Each string will be a member of exactly one group. We would like to be able to see whether two strings are in the same group...
-
Why do you and your business need to be able to communicate well?
-
What are the basic criteria for effective messages?
-
What are the questions for analyzing a business communication situation?
Study smarter with the SolutionInn App