Hello everyone, I've got a class that extends JFrame with 2 panels inside it. I'd like to draw rectangles of varying heights in the right panel, however, everything that I have tried so far has failed. The rectangle is declared globally, and its properties are defined in a method as such:
paintComponet looks like this:
At present, nothing shows up on screen. What I'd like to do is specify the rectangle to paint inside the right panel. Any pointers would be appreciated. Thank you all. [ November 23, 2003: Message edited by: Malcolm White ]
Each component is responsible for painting its own self (by default, anyway.) If you were to move the paintComponent() method into the right JPanel (i.e., subclass JPanel and add your method) you'd find that it would work. As it is, when that JPanel is painted, it erases its region of the screen, obliterating your efforts. Alternatively, you could get this to work by again subclassing JPanel so that its paint() method did absolutely nothing -- but it would be fiddly. Easier to do it the right way.