Skip to main content
gamedev.net
🔒 Locked

[java] Buttons and Games

Started by Crosseyed 2 replies 600+ views
Original Post
Crosseyed
Crosseyed
Ok, here is my situation. Im making a java applet that i would like to have buttons of some sort to perform actions such as zooming or scrolling the view. Originally i was planning on using layouts and all the AWT features to setup the buttons and other GUI stuffs. Then have a Canvas or Panel for the display. However none of the learning resources i was using expained how i could do this, and all my attempts ended with canvases that werent being painted on. So is it even possible to mix realtime games and AWT/Swing or do i need to go about making my own GUI features. My original plan was to use border display with the center being the game display(a canvas) and the south containing buttons, but i have since switched to using the entire appplet surface as the display. Thanks!
Jiim
Jiim
I have a tutorial on this kind of thing over at www.javage.net, I think this is the kind of thing you are looking for!

Jiim Jonez
nonnus29
nonnus29
Hey Jiim good to see your site is back up. (I haven''t been able to view it for months; it was a giant picture of a keyboard for a long time.)

One problem with that tute is: Its a SWING button, yucky!
Petr Stedry
Petr Stedry
quote:

So is it even possible to mix realtime games and AWT/Swing or do i need to go about making my own GUI features.


It is possible.
Just don''t forget that processing of GUI events is contained within ONE thread. So if you plan to combine the standard Swing GUI elements with you bussiness logic & custom view, pass all info from the events to your Thread - make the "event" methods return ASAP & process the information (change the state of the game) inside your thread.
P.S.: If you call the repaint() method of your Canvas/JPanel it is repainted. If it does not, check if you call super.paint(Graphics) in your paint method, that does override the paint method from the Canvas/JPanel.

have fun ...


Petr Stedry
Petr Stedry

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.