The call to setOpaque(true) should be moved up into the constructor; it only needs to be called once. Similarly, the call g.setColor(Color.black) can be moved up above the for loop. It's okay to override the paint method in your JComponent class. For custom drawing in which you do not want/need to draw over child components it's better to override paintComponent
The setBackground call won't do anything in the JComponent unless you use it like this
Even easier is to extend JPanel instead of JComponent. Then you can place the setBackground call in the constructor, omit the setOpaque call and
Joined: Oct 17, 2005
Thanks alot! thats spot on. Thanks for the tips also, theres always room to improve!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: setLocationRelativeTo(null) - problems with setBackground