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


 Exercise 3A [5%] Create a class called Letter2DDisplay. Extend this class from

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

1 Expert Approved Answer
Step: 1 Unlock

Heres a possible implementation of the exercises described import javaxswing import javaawt import j... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!