Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 3A [5%] Create a class called Letter2DDisplay. Extend this class from JComponent. Add a private variable of type Letter2D []. If you have


 image text in transcribed

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);

Step by Step Solution

3.40 Rating (150 Votes )

There are 3 Steps involved in it

Step: 1

Heres a possible implementation of the exercises described import javaxswing import javaawt import j... 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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions