Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (788)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (863)
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  
  Swing Applet - Sometimes doesnt display..  (Read 2393 times)
0 Members and 1 Guest are viewing this topic.
Offline steveyO
« Posted 2009-07-27 22:24:39 »

Am really struggling with an issue.. Any pointers appreciated.

I have some Multiplayer Java Swing Applets on my new site.  Approximately once every 10 times, the main panel doesnt display (just a completely white applet)..  I have debugged and there seems to be no difference in the panel creations between the working and non-working version (well of course apart from it being displayed)...  Have upgraded to latest Java version and still doesnt fix..  + interestingly on my laptop when using Firefox, clicking on the applet when it doesnt display fixes it.. And in Internet Explorer moving the browser scroll bar also fixes the problem (but on my desktop with same version of FF clicking doesnt fix, ie.  applets is still blank)... When running from eclipse it fails to display less often (approx 1 in 25).  Removing the loading of images doesnt fix either..

Am at a bit of loss what to try next.. Anyone experience anything similar?  2D Game Editor + Random Graphics Generator
Offline markmistry

Junior Devvie

« Reply #1 - Posted 2009-07-28 01:24:36 »

yeah my sis was havin same problem on her laptop dont know what os or browser.. she was in my game next she said it had white screened,never happened to me all the 500 million times i have tested it?Huh very strange. could have been the reason why she wasnt speaking to me in my
my swing box starts when my game starts in an applet.would be nice to know what causes it.
Offline steveyO
« Reply #2 - Posted 2009-07-28 19:03:57 »

ok will let u know if ever find the problem.. Just spent another hour with no luck..
Have had similar problem in past and found that using a MediaTracker for loading images solved.. but this isnt the case for me.. Its bloody annoying.  2D Game Editor + Random Graphics Generator
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline erikd

JGO Ninja

Medals: 16
Projects: 4
Exp: 14 years


« Reply #3 - Posted 2009-07-28 21:35:50 »

My first thought is that you might be doing something on another thread than the AWT event dispatch thread where you should, but it's difficult to tell for sure without seeing some code.
Maybe you should try to come up with a small test case and post the code here.

Offline Wildern

Junior Devvie

« Reply #4 - Posted 2009-07-29 15:57:52 »

It sounds like you might be using paint/repaint to control your game loop and are relying on an external trigger to cause the first paint.
But I am just guessing... can't really do more than that without seeing some code  Undecided
Offline steveyO
« Reply #5 - Posted 2009-07-29 19:46:22 »

Thanks for the suggestions.. Unfortunately cant post any code as there are loads of classes involved (using an open source API).  My guess at the moment is its thread related (hence why am struggling, will look t the AWT event dispatch stuff.. not too familiar)..  Have tried some stupid fudges like calling my panel repaint 5000 times after it is initialized and this significantly reduces the blank applet occurences but doesnt fix.. Its annoying,,can sometimes refresh my browser 50 times without seeing it and then it happens 3 or 4 times in quick succession.  Would much rather be coding new games than debugging but has to be done.. Urgh.  2D Game Editor + Random Graphics Generator
Offline Wildern

Junior Devvie

« Reply #6 - Posted 2009-07-30 03:32:42 »

If calling repaint helps, perhaps you need an update method...  and all of your offscreen image creation/loading should happen in addNotify()

public class Foo extends Applet implements Runnable {
   public void update(Graphics g) {
   public void addNotify() {
Offline steveyO
« Reply #7 - Posted 2009-07-31 19:57:15 »

Thanks for suggestion Wildern... The below didnt quite work for me as part of the applet components are  partially declared in init() and  then when a connection to the server is established ..
Luckily 'Touch Wood' it looks like I have fudged it.. I am calling panel.repaint() and panel.revalidate() 1000 times before and after adding the main panel and it seems to fix 'i.e. fudge fix' it... Phew!!  Dont really know why but tbh.. dont really care  Smiley  2D Game Editor + Random Graphics Generator
Pages: [1]
  ignore  |  Print  

hadezbladez (2208 views)
2018-11-16 13:46:03

hadezbladez (832 views)
2018-11-16 13:41:33

hadezbladez (2163 views)
2018-11-16 13:35:35

hadezbladez (432 views)
2018-11-16 13:32:03

EgonOlsen (3471 views)
2018-06-10 19:43:48

EgonOlsen (3723 views)
2018-06-10 19:43:44

EgonOlsen (2283 views)
2018-06-10 19:43:20

DesertCoockie (3020 views)
2018-05-13 18:23:11

nelsongames (3093 views)
2018-04-24 18:15:36

nelsongames (3910 views)
2018-04-24 18:14:32
Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20 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!