Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getGraphics and repaint

Status
Not open for further replies.

Tallaria

Programmer
Dec 2, 2005
1
DK
Hi

I am using Jess a language besed on java to program, but I am using the java commands to draw. So I can not post a java example, but if you know the answer in java, I can translate the suntax myself.

I have made a draw funktion, that draws a square on one of the panels in my frame.
I have used the getGraphics method on my panel, and then called graph.fillRect(...)
This funktion has to be called several times, with different coordinates for the rectangle. And this works.

My problem is, that if I use repaint on my frame in the function, my objekt disapear after a split-second. If I don't use repaint, my objekts disapear when I minemize, resize or open anothe frame over the window.

How do I make my objekt stick to the panel so I can mimemize and resize my window?

Thanks for any help in advance
 
You said you are calling repaint on the Frame. I would just call repaint on whatever component you are drawing on (JPanel?). Also, if you are not using Java Swing, make sure you utilize double buffering to avoid the 'flickering'. If you are unsure, double buffering is the practice of drawing your image off-screen, then calling the paint() method on your component.

That's a real short answer...I'd recommend a good Googling!

Rich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top