Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (568)
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 1177 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?

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
Offline markmistry

Junior Member





« 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 chat..lol
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.

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
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


Maximumisness


« 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 Member





« 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.

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
Offline Wildern

Junior Member





« 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()

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public class Foo extends Applet implements Runnable {
...
   public void update(Graphics g) {
      paint(g);
   }
...
   public void addNotify() {
      super.addNotify();
      initialize();
   }
}
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

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (20 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (28 views)
2014-09-21 23:33:17

BurntPizza (64 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (42 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!