This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes a.update(a.getGraphics()); Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "a.update(a.getGraphics());" Watch "a.update(a.getGraphics());" New topic
Author

a.update(a.getGraphics());

Paul muellerl
Greenhorn

Joined: Dec 09, 2012
Posts: 7
Hey guys,

can anybody tell what I have to do that when I use a.update(a.getGraphics()); in my Gui and my Window is always refreshing?
But actually I just want du refresh my Gui.
I tryed it with this

I think I´m nearly there....



Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

There's so much wrong there that I'm not going to even try to answer the question you asked. Instead I'm going to point you to the tutorials on Performing Custom Painting and How to Use Swing Timers.

Oh, and you do know there's a repaint() method, don't you?


luck, db
There are no new questions, but there may be new answers.
Paul muellerl
Greenhorn

Joined: Dec 09, 2012
Posts: 7
I know there is a repaint method but it dosne´t work,
When I use repaint they just draw me the finish picture.


AND there can´t be so mutch wrong... it works... the only thing is that there is a flickering.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Paul muellerl wrote:When I use repaint they just draw me the finish picture.


Yes, that's what it's for. Once you read and understand the custom painting tutorial you have a better chance of understanding how to do it right.

AND there can´t be so mutch wrong... it works... the only thing is that there is a flickering.


Maybe that's so, but you can't modify it to do what you want. Instead you have to stop, go back, and start down the right road. To do that it would be best if you read the tutorials which Darryl linked to. And then, write code like the code in those tutorials.

(What I usually do when I'm learning a new Java topic: I go through the tutorial. Then I download the sample code and start changing things in it, so that I am sure I understand it. Then I keep changing things in it until it turns into the code which I originally wanted to write.)
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> AND there can´t be so mutch wrong... it works... the only thing is that there is a flickering.

you seem to have a hard time believing what we've been telling you, and it's not a language problem.

here's 2 demo programs to prove to you the problems that will bite you when you least expect it.

1) using Thread.sleep in Swing is a no-no, it blocks painting and listeneing
run this, it will only last 5 seconds, but you cannot close the program in that 5 seconds,
and the label text will not appear until the while loop stops (which is the thread.sleep stopping)


2) getGraphics() is another no-no (generally) in Swing
run this, Hello World will appear, now minimize the frame then immediately restore it,
the text will disappear, as getGraphics() draws once only
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a.update(a.getGraphics());
 
Similar Threads
Need help putting comments in
Table Viewer GUI from a Database
Tidying up my code?
Gui components disappearing
Trying to get manageable arrays to work with