Results 1 to 6 of 6
- 03-02-2011, 07:42 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 10
- Rep Power
- 0
Switch Case with Repaint Flcikers
I am very new to applets. I was wondering if anyone can help me with this. This applet takes user input as a single number digit on the button click, then draws it in rectangular form. But it keeps flickering when using repaint(). I'm not sure if there is a way to clear the whole applet then repaint this or what other methods would do this correctly. any help would be appreciated.
Last edited by poorbrain; 03-03-2011 at 02:44 AM.
- 03-02-2011, 09:22 PM #2
Senior Member
- Join Date
- Feb 2011
- Posts
- 118
- Rep Power
- 0
Why are you calling repaint() *before* filling your rects? You shouldn't need to call it at all.
- 03-02-2011, 09:29 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 10
- Rep Power
- 0
if I take out repaint, it just stays at the default rectangle shape. Or if i put it at the end of the switch case before the break statement it does the same thing, just stays digit of 0 even if I change it to any other digit.
- 03-02-2011, 09:32 PM #4
Member
- Join Date
- Mar 2011
- Posts
- 10
- Rep Power
- 0
correction, if i take it out it wont change but if i put it at the end it does the same thing and flickers
-
Agree having repaint inside of a paint method is simply crazy. Of course this thing will flicker to death. Wouldn't it be much smarter to call repaint in the actionPerformed method, after updating num?
Better still is to do all of your drawing in the paintComponent method of a JPanel, not the paint method of a JApplet.
- 03-02-2011, 10:05 PM #6
Member
- Join Date
- Mar 2011
- Posts
- 10
- Rep Power
- 0
eh, I thought I already tried putting repaint in the actionPerformed method.......
eh i guess not... works now fine. thanks a lot for the help I really appreciate it, been messing around with changing the code around and google searching for about a hour or two. then remembered these kind of forums had helped me out before.
I hate stupid simple fixes like this, spend all this time for something so simple. has happened to me many times before.
Similar Threads
-
Converting if to Switch Case.
By king2be98 in forum New To JavaReplies: 5Last Post: 02-20-2011, 03:46 PM -
Switch Case statement
By seanfmglobal in forum New To JavaReplies: 7Last Post: 02-15-2011, 01:18 PM -
if else changes to switch-case?
By noobinoo in forum New To JavaReplies: 1Last Post: 04-23-2010, 05:56 PM -
[SOLVED] Is it possible to have If in a switch case?
By sfe23 in forum New To JavaReplies: 2Last Post: 02-23-2009, 12:34 AM -
Switch Case and Key Events
By AndrewM16921 in forum New To JavaReplies: 4Last Post: 01-26-2009, 11:20 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks