Results 1 to 10 of 10
- 06-21-2010, 05:21 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 23
- Rep Power
- 0
-
without your showing code, I think that most will not be able to answer your question. Please look at the link in my signature about creating an SSCCE. If you follow the recommendations in this link, you'll be able to post a small program that we can more easily analyze, adapt and improve and thus answer your question. Also, when you state "active rendering" do you mean that you are not rendering in a component's paint method or a JComponent's paintComponent method? And if so, why? Is this game programming?
Much luck!
- 06-21-2010, 05:58 PM #3
Member
- Join Date
- Mar 2010
- Posts
- 23
- Rep Power
- 0
Yes this is game programming, and im using fullscreen mode.
Here is how I paint the screen:
Java Code:public void gameLoop() { long startTime = System.currentTimeMillis(); long currTime = startTime; while(isRunning) { long elapsedTime = System.currentTimeMillis() - currTime; currTime += elapsedTime; // update update(elapsedTime); // draw the screen Graphics2D g = screen.getGraphics(); draw(g); g.dispose(); screen.update(); try { Thread.sleep(20); } catch(InterruptedException e) { } } }Java beginner.
-
Hm, I don't do active rendering, so I'll be limited help here -- hopefully someone else more versed in this and Java game programming will pitch in, but I wonder if you will need to implement double buffering yourself if you do this. Also, perhaps you want to redraw the smallest Rectangle possible rather than the whole screen every 20 ms.
- 06-21-2010, 07:55 PM #5
Member
- Join Date
- Mar 2010
- Posts
- 23
- Rep Power
- 0
My draw() method implements double buffering.
My problem is flickering when using swing objects when in fullscreen mode.Java beginner.
-
You may wish to consider creating and posting an SSCCE that demonstrates your problem (please see the third link in my signature). If you do this, remember that the simpler and smaller your code, the easier it will be to analyze and the more help you'll likely get.
Luck!
- 06-21-2010, 11:16 PM #7
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Where did you learn about active rendering? Presumably there was an example posted with the tutorial. Does the example work?
Swing is double buffered by default and I don't think you need to go to all the trouble. I suspect the tip you found was for AWT which in nont double buffered.
Painting in Swing and AWT is different so the same tips do not apply to both.
- 06-22-2010, 08:37 AM #8
Member
- Join Date
- Mar 2010
- Posts
- 23
- Rep Power
- 0
From the book "Developing games in java" by David Brackeen.
Java beginner.
- 06-24-2010, 03:15 AM #9
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
Actively Rendering Swing Components.
You need to actively paint your Swing components in that loop as well. A full detailed example can be found at:
JamesGames.org | Resources | Double Buffering and Active Rendering Guide | Double Buffering and Active Rendering in Java with Swing Integration
Basically, you need to set some of your Swing component's backgrounds to not be opaque, ignore repaints by Java, and then actively paint the Swing components in your loop.
Let me know if you have any questions.
- 06-26-2010, 03:16 PM #10
Member
- Join Date
- Jun 2010
- Posts
- 26
- Rep Power
- 0
Similar Threads
-
how to make graphic 'painted' on a button visible after disabling??
By nit_go in forum AWT / SwingReplies: 2Last Post: 01-30-2010, 05:14 AM -
AWT scaling the window to the thing that is painted
By chappa in forum AWT / SwingReplies: 16Last Post: 01-04-2010, 06:34 PM -
problem: lightweight component still being painted after remove
By LittleRave in forum AWT / SwingReplies: 3Last Post: 12-10-2009, 03:07 PM -
Problem in JSP rendering
By srkumarj2ee@gmail.com in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 09-27-2009, 02:02 AM -
Help with JTable rendering
By daniel2008 in forum AWT / SwingReplies: 8Last Post: 01-18-2009, 03:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks