luck, db
There are no new questions, but there may be new answers.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
4
posted
0
Moving to GUI forum.
By "fluctuates" I presume you mean "flickers"?
Go into the API for whichever component you are painting on, and have a look at its constructors. You will probably find an overridden one with a boolean called doubleBuffered or something similar. Try putting "true" in that constructor. That might help.
Muhammad usman shad
Ranch Hand
Joined: Jan 06, 2010
Posts: 30
posted
0
Dear Campbell,
I am not using the buffer for painting.
I am drawing a bar graph on x and y axis..
The graph gets the axis values from user and draw the graph bars one by one...
When first bar appears that is well but when second to onwards bars appear,
It isn't possible to guess what you might have done wrong from your description. To get better help sooner, post a SSCCE* that clearly demonstrates your problem.
If the area is large what your program is painting then use buffering as recommended before, or call repaint(Rectangle) to repaint only renewing area (if it aint the whole area)
Muhammad usman shad
Ranch Hand
Joined: Jan 06, 2010
Posts: 30
posted
0
Here is the code of the graph...
Do follow the constraints wriiten on the JFrame...
And then post me the code which is anti-flickered...
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
do you know what this does
repaint();
when called from paintComponent()?
Muhammad usman shad
Ranch Hand
Joined: Jan 06, 2010
Posts: 30
posted
0
Yes,
It repaints the screen...
But did you execute my program???
If yes,
then what is the solution???
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> It repaints the screen...
which calls paintComponent(..)
which contains repaint()
which calls paintComponent(..)
which contains repaint()
which calls paintComponent(..)
which contains repaint()
which calls paintComponent(..)
which contains repaint()
which calls paintComponent(..)
which contains repaint()
do you now understand?
Rok Štelcer
Ranch Hand
Joined: Nov 03, 2009
Posts: 101
posted
0
Remove repaint(), as Michael already said ...
SCJP, SCWCD
Alex Parvan
Ranch Hand
Joined: Dec 10, 2009
Posts: 115
posted
0
You can't call repaint() inside the paintComponent() method because repaint() calls paintComponent(). What you should do is either create a thread, either use a listener event.
I wrote you a quick program so you can understand:
This should clear things up.
vijay jamadade
Ranch Hand
Joined: May 12, 2008
Posts: 224
posted
0
......
[MG]Removed hijack
Regards, Vijay Jamadade.
( Nothing is Impossible.)