Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 19, 2013 7:12 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Feb 26, 2012 9:38 pm 
Offline

Joined: Fri Jan 06, 2012 2:15 am
Posts: 44
These tests seem to work but they don't exit correctly when you click the close button. Does anyone else see similar behavior? For me the black background changes to white (GL view stops?), but the frame stops responding. Do the tests shut down incorrectly?


Top
 Profile  
 
PostPosted: Sun Feb 26, 2012 10:13 pm 
Offline

Joined: Fri Jan 06, 2012 2:15 am
Posts: 44
Yeah looks like it, works when doing this:

Code:
   private static CanvasGameContainer container;
   /**
    * Entry point to our test
    *
    * @param argv The arguments to pass into the test
    */
   public static void main(String[] argv) {
      try {
         container = new CanvasGameContainer(new CanvasContainerTest());
         
         JFrame frame = new JFrame("Test");
         frame.setLayout(new GridLayout(1,2));
         frame.setSize(500,500);
         frame.add(container);
         
         frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
         
         frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {

               container.setEnabled(false);
               container.dispose();
            }

            @Override
            public void windowClosed(WindowEvent e) {

               System.exit(0);
            }
         });
         frame.setVisible(true);
         container.start();
      } catch (Exception e) {
         e.printStackTrace();
      }
   }


Top
 Profile  
 
PostPosted: Mon Feb 27, 2012 9:00 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
I do it like this to ensure I close right. You ALWAYS should perform the close on the EDT! Like this:
Code:
EventQueue.invokeLater(new Runnable() {
   public void run() {
      frame.setVisible(false);
      glCanvas.getContainer().exit();
      Display.destroy();
      System.exit(0);
   }
});


This way the window fades out still displaying the Display Canvas and the exits the game in a clean way. At least that works for me :)

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Tue Feb 28, 2012 1:16 am 
Offline

Joined: Fri Jan 06, 2012 2:15 am
Posts: 44
Oh yeah, good call, forgot about the EDT (used to a single threaded UI model these days!)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group