Question about swing components & canvas

I got most of my stuff animated and working fine, I wanted to throw in some buttons like "new game"etc etc, to make the interface more “organized”.

I used the template provided in this site, problem is when I add the button to the panel, the canvas won’t let the buttons display or something like that… not really sure what’s going on…

Another question, is it possible to add swing components to the canvas?

thanks

A Canvas is not a container so you can’t add components to it. Your best bet is to have a JPanel that has all your widgets in it. One of the widgets that you add to it should be your custom drawing panel. That panel can be a Canvas or you can also use JComponent. The only draw back to JComponent is that you won’t have a buffer strategy. Something like this:


JPanel using BorderLayout
--------------------------------------------------------
|                                                      |
|        Title/Logo                                    |
|------------------------------------------------------|
|            |                                         |
|            |                                         |
|            |                                         |
|            |                                         |
|            |                                         |
|            |                                         |
|            |         Game display                    |
| Buttons    |                                         |
|   etc      |                                         |
|            |                                         |
|            |                                         |
|            |                                         |
|            |                                         |
|            |                                         |
|            |                                         |
|            |                                         |
--------------------------------------------------------