This is based on one of the examples in Head First
Java... it plays some notes using MIDI, and each time a MIDI controller event is fired, it draws a colored rectangle on screen.
Instead of using their rather klugey method of drawing shapes, I created an inner class RectShape so that I could associate some random dimensions with a color, and also conveniently store them in an ArrayList, so that I can redraw the whole lot when the panel needs repainting.
The important bits are the bottom two sections of code.
2 questions about my RectShape class:
1) Is it really bad just to declare its fields and values like this, without using a constructor method?
2) Is it OK to use the fields directly in my JPanel's paintComponent(...) method, since it's an inner class? Or should I still use getters / setters (seems a bit long-winded).
To me it seems more elegant to make the concisest code possible, but you guys might disagree...