This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm trying to do some custom drawing via a JComponent. I can get the frame to show, but unfortunately I can't seem to get the graphics to appear. Here is a minimal version of my code.
What do I need to do to get the rectangle to be drawn? Also, setting the minumum and preferred size of the JComponent seem to be to only way to get the JFrame to render in a non-minimized form. Are there better ways?
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
You aren't telling the system where to draw the rectangle.
Joined: Jan 17, 2006
Thanks for the help Gregg. The problem was actually something different, and a little wierder to me. It wasn't that the image wasn't getting rendered, it had to do with the WIDTH and HEIGHT constants. I added a some logging statements and got this: