The canvas game container has undergone some changes and bug fixes recently, so I'd recommend pulling the latest code from the
dev branch.
I've updated the tests, as well. If you don't want to pull the latest changes, the new test code should (in theory) also work on older versions of Slick, give or take some minor bugs.
The tests work like this:
CanvasContainerTest - shows how to use a canvas game container to achieve a "fixed-size" game; i.e. you can resize the JFrame and it won't resize the actual game. Also, the game will be centred in the JFrame.
CanvasSizeTest - simple use of CanvasGameContainer; resizing our JFrame will resize the game as well.
Regarding your two problems:
- You need to call System.exit when closing the frame. Either manually, or using JFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE). Also, it's good practice to destroy OpenGL before closing, with GameContainer.exit. In the tests you'll also see that I hide the frame before destroying OpenGL; this just looks a bit better than leaving it open as the OpenGL canvas is lost.
- By default, game containers don't update/render if the container (in this case the canvas) is not active/focused. So I've included a requestFocusInWindow method which should solve this. You could, instead, use GameContainer.setAlwaysRender(true) to avoid this issue.