aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Drawing in Graphic-Context of a JPanel in a JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Drawing in Graphic-Context of a JPanel in a JPanel " Watch "Drawing in Graphic-Context of a JPanel in a JPanel " New topic
Author

Drawing in Graphic-Context of a JPanel in a JPanel

Raschin Ghanad
Greenhorn

Joined: Jul 28, 2004
Posts: 10
I have a Panel that has a Panel inside (to get some inset in my Panel.)
The problem is, that it just works, if I draw into the main Panel.
If I try to get the Graphic context of my other JPanel and write into it,
I just see my drawing for breaks of seconds when I rezise the Frame (where the JPanelis inside).
If I don't resize, I see nothing, if I finish resizing, the same.

Here ist my Code.
Maybe the paint-Method is just called when resizing now?

Can anyone help ?
Is there another possibility to get some inset for my drawing Area?

Here is my Code:




[ July 29, 2004: Message edited by: Raschin Ghanad ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8873
    
    8

Since you didn't override screenPanel's paint method, it is probably painting itself over your own paint efforts. Have a gander at the Custom Painting chapter of the Java Tutorial for some more detail.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Raschin Ghanad
Greenhorn

Joined: Jul 28, 2004
Posts: 10
yes, thats what I was thinking about, too.
But how can I override it without creating a new class that extends a JPanel and then adding it?

Can't I use my actual paint-Method to write into the Graphic-Context of the the component using the getGraphcis() method?


Sorry, I haven't time to read the tut, but I will do so in a while.

thanx for fast response
[ July 29, 2004: Message edited by: Raschin Ghanad ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Drawing in Graphic-Context of a JPanel in a JPanel