Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (687)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Killer Game Programming's Animation Framework Being Wrong on: 2013-03-14 19:35:26
awt is thread-safe

Huh?  You do know that Swing uses the AWT event dispatch thread (EDT), right?  Wink

AWT is equally single-threaded and not thread-safe -

Seems like this book had already been outdated when it was printed. Because as far as I know the change in Swing rule was made in 2004.

No, Swing has always been single threaded.  The "rule" that changed was around creating components off the EDT before they were realised (ie. before making them visible).  It's now recommended to always create components in the EDT.

However, active rendering to an AWT or Swing component is OK.  I'd recommend a Canvas, and searching for information on using BufferStrategy.

While painting to the component is OK, I'd recommend building and displaying the window and canvas on the EDT first.  You also should probably use setIgnoreRepaint(true) to stop the component trying to respond to paint requests from the EDT.

Hello. Thanks for the reply.

Can you give more specific information on why it's OK to paint ? Doesn't painting mean modifying? Is every painting function thread-safe or what?

I use this method to create the Frame and the JPanel. GameMain contains the code to instantiate and show JFrame.

 public static void main(String[] args) {
      // Use the event dispatch thread to build the UI for thread-safety.
      SwingUtilities.invokeLater(new Runnable() {
         public void run() {
            new GameMain();
2  Game Development / Newbie & Debugging Questions / Killer Game Programming's Animation Framework Being Wrong on: 2013-03-14 18:10:12
Hello. I'm a new member here.
While I'm not a newbie in Java, I've just started to game programming. And I need your advices on this.

In the resources page of the site (, I've seen that "Killer Game Programming in Java - Andrew Davison" is one of the recommended books.

I have been trying to read this book for a while but I have discovered that the animation framework presented in the second chapter of this book is wrong. Because in Java tutorial it's said that GUI components should be accessed (created, modified, queried, etc.) only in EDT (Event Dispatch Thread). But in Killer Game Programming, animation is controlled by another thread. And it uses a technique named 'Active Rendering' which doesn't event use method repaint. Instead, it tries to get graphics context of JFrame in order to render everything by itself. It uses JPanel from another thread therefore violates Swing's single thread rule.

Seems like this book had already been outdated when it was printed. Because as far as I know the change in Swing rule was made in 2004.

Since you recommend this book to newbies, can you enlighten me? What should I do? Should I continue reading a wrong book? Am I the wrong one?
Pages: [1]
Dwinin (72 views)
2015-11-07 13:29:08

Rems19 (81 views)
2015-10-31 01:36:56

Rems19 (77 views)
2015-10-31 01:32:37

williamwoles (107 views)
2015-10-23 10:42:59

williamwoles (93 views)
2015-10-23 10:42:45

Jervac_ (110 views)
2015-10-18 23:29:12

DarkCart (135 views)
2015-10-16 00:58:11

KaiHH (117 views)
2015-10-11 14:10:14

KaiHH (156 views)
2015-10-11 13:26:18

BurntPizza (172 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!