Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (623)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (676)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  JApplet:  JFrames errors when returned to App  (Read 949 times)
0 Members and 1 Guest are viewing this topic.
« Posted 2004-04-13 21:35:46 »


Please excuse if this post should not appear under this topic.  I'm doing some drawing on a panel in a JFrame that's created from an applet.  When a button is pressed on the applet a Window pops up and there are various components and drawings on that panel.  

Everything works great when the page is first loaded.  When I leave the page to go to say then click the back button to return to the page, the JFrame no longer displays the components, draw anything or recognize any events sent to Swing components on this JFrame.  

What is being done when I leave my page in IE to go to a different one then click back?  What should I do or check to make sure my applet works correctly when I leave then return to the page?

Offline nonnus29

Senior Devvie

Giving Java a second chance after ludumdare fiasco

« Reply #1 - Posted 2004-04-14 00:35:18 »

JFrame and JApplet are both top level containers, and heavyweights.   In Swing you are not supposed to mix heavyweights with heavyweights.  I've experienced erratic behavior when trying to mix the two as well.  I even went so far to use a JPanel to re-implement an applet to use in a JFrame.   Worked great  Wink

Maybe you should reconsider your design; why does your JApplet need a JFrame? JApplet has menubars etc so what is the advantage of adding using a JFrame? JApplet should only contain other lightweight components.
Offline javawillie

Junior Devvie

Hola, Paco.

« Reply #2 - Posted 2004-04-14 16:23:17 »

Mixing JApplets and JFrames does not cause a problem in Swing--at least I have never seen that or heard of that.  (I could be wrong, but if I am, I'd be very interested and grateful to be enlighted with a relevant link or explanation.)  The problems arise when one tries to add a heavyweight object to a lightweight object.  Besides, JFrames are not added to the applet's container tree anyway.

Also it is often useful to have JFrames in applets.  For example you might want to allow the user to resize the UI.  We do this pretty often where I work.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
« Reply #3 - Posted 2004-04-14 16:53:35 »

Hi all,

Well I got it to display the JFrames correctly now when the 'Back' button is pressed.  All the panels are now repainted fine when I return to the page, but the JTextFields (Except for the first one clicked) no longer accept input or focus requests.  All other components like radio buttons do.

When I click on the first JTextField it get's the focus and the cursor, but the following JTextField no longer get's any focus when clicked.

I noticed also that when I reinstantiate a single major JPanel I have on my applet, everything works fine and I can press back as many times as I like and there are no problems.  I might stay with that but I would like to maintain as much of the applet current state as I can when the user returns to it.

I'm starting to think that it's probaby an event queue problem, or something to do with listeners added to components.  Since I have no idea what IE does to an applet when a user leaves a page, it's hard to tell.


BTW, I'm not adding JFrames to the JApplet.  I'm creating new windows using JFrames from within panels that have been added to the JApplet.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

BurntPizza (32 views)
2015-10-08 03:11:46

BurntPizza (17 views)
2015-10-08 00:30:40

BurntPizza (19 views)
2015-10-07 17:15:53

BurntPizza (32 views)
2015-10-07 02:11:23

KaiHH (38 views)
2015-10-06 20:22:20

KaiHH (16 views)
2015-10-06 19:41:59

BurntPizza (32 views)
2015-10-06 19:04:48

basil_ (47 views)
2015-09-30 17:04:40

shadowstryker (26 views)
2015-09-29 15:55:06

TheSpaceHedgehog (32 views)
2015-09-29 01:58:48
Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!