Skip to main content
gamedev.net
🔒 Locked

[java] Swing component visibility problem within Applets

Started by Spudder Nov 8, 2004 at 1:26 PM 2 replies 1k views
Original Post
Spudder
Spudder
I've got a simple animation JApplet up and running which has some Swing controls (JButtons) added to adjust various animation settings. The problem is these components don't become visible until I click the area on the applet where the control has been added to, I'd lke them to be visible from when the applet loads. I know I'm not drawing over the control because when it becomes visible it remains visible. I've looked through the Java API docs and couldn't find anything so any help on this matter would be greatly appreciated.
Koroljov
Koroljov
Put the animation in a separate JPanel. Don't put the controls in the panel that you use to paint your animation on.
Why do my programs never work on other computers?
Spudder
Spudder
I tried adding the controls to a separate JPanel but it didn't work, unless I'm missing something?
Koroljov
Koroljov
You added the controls on a separate JPanel, and you put the JPanel in the JApplet, right? And then you draw the animation on the JApplet, right?

Then your controls are still in the same Container as your animation, and therefore you draw over your controls. You really should make a class extends JPanel, override its paint and update methods, and use it to display your animation. Then you can put the controls and the animation JPanel in the JApplet.
Why do my programs never work on other computers?

Topic Locked

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

Sign in to reply to this topic.