• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Drawing in Graphic-Context of a JPanel in a JPanel

 
Raschin Ghanad
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9295
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raschin Ghanad
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic