Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Screen is flippering / flickering.

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Screen is flippering / flickering.

    .


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,334
    Thanks
    181
    Thanked 830 Times in 773 Posts
    Blog Entries
    5

    Default Re: Screen is flippering / flickering.

    Flickering can be caused by a great number of things, more often than not it can be due to incorrectly drawing to a JPanel (assuming you are doing this - as your post doesn't mention anything about Swing). Post an SSCCE to clarify the issue and demonstrate the flickering.

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,453
    My Mood
    Hungover
    Thanks
    144
    Thanked 638 Times in 546 Posts

    Default Re: Screen is flippering / flickering.

    Sorry, but that's not an SSCCE- an SSCCE should be short, self-contained, compilable, and an example of what's happening to you. It's really hard for us to troubleshoot a problem without an SSCCE. Including all your code is definitely overkill, so I recommend you narrow it down and eliminate everything that's not directly related to the problem. For example, stop drawing one of your on-screen items. Does the problem still persist? Then take out another one. Continue that process until you've narrowed it down to a single problem.

    That being said, what is the point of redrawing everything in a loop? That definitely sticks out to me as something that could cause the behavior you described.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,334
    Thanks
    181
    Thanked 830 Times in 773 Posts
    Blog Entries
    5

    Default Re: Screen is flippering / flickering.

    "Long SSCCE" is an oxymoron.

    You've got 3 nested loops in your paintComponent...anything with this many nested loops will take some time. If you are animating, make sure you are not making calls to getGraphics and all things are dispatched to the EDT (you did not post anything of the sort, which is why I asked for a SSCCE)

    From what you posted I can fathom a guess your paintComponent is clogging up given it is taking a while to draw. You can test this by profiling your paintComponent (print out how long it takes to draw) or removing some lines of code to see if this helps. If either tells you the method is just taking too long, you will need to optimize your drawing in one way or another.

Similar Threads

  1. Replies: 9
    Last Post: December 31st, 2011, 12:22 AM
  2. Double buffered Image is flickering
    By jay-wo in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 29th, 2011, 11:21 PM
  3. JPanel flickering
    By Ghosth in forum AWT / Java Swing
    Replies: 1
    Last Post: April 30th, 2011, 10:52 AM
  4. Java swing buttons are flickering in windows 7 environment
    By javasam in forum Member Introductions
    Replies: 1
    Last Post: February 17th, 2011, 08:51 AM
  5. Java swing buttons are flickering in windows 7 environment
    By javasam in forum AWT / Java Swing
    Replies: 1
    Last Post: February 14th, 2011, 11:13 AM

Tags for this Thread