Jump to content

  • Log In with Google      Sign In   
  • Create Account

[java] This code works in appletViewer but not browser, please help...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 nowan   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 May 2001 - 03:18 AM

The following code which comes from my run() method works fine in appletViewer but not in my IE 5.0 browser. The code is for a simple countdown clock during which you must complete the game. The clock displays but will not countdown when tested in the browser. *********************************************** if(secs>0 && gameStart==1 && gameOver==0) { secs--; // clock countdown } if(secs<=4 && secs > 0 && TimersoundPlayed==0 && gameOver==0) { TimerSound.play(); TimersoundPlayed=1; } if(secs<=0) { gameOver=1; } *********************************************** What do you think is going wrong?

Sponsor:

#2 lilspikey   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 May 2001 - 05:44 AM

That''s not really enough code, but try compiling with the option -target 1.1 , you might be using some 1.2 code.

#3 nowan   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 May 2001 - 08:55 PM

Thanks lilspikey, but I''ve tried what you suggested with no success. Any other ideas?

Thanks

#4 lilspikey   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 May 2001 - 10:53 PM

So what error does it give?

#5 nowan   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 May 2001 - 12:08 AM

Well, if I look in the Java console part of the browser I do get the following message but I still get it if I comment out the code I posted and re-compile without it.

java.lang.NoSuchMethodError: java/awt/Component: method getWidth()I not found
at Connections.run
at java/lang/Thread.run

#6 nowan   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 May 2001 - 12:11 AM

Also, I forgot to mention, if I use HTML converter everything works perfectly but this means that the end user has to download a plug-in I think, which kind of counters the whole point of me using Java for a web-based game.

#7 lilspikey   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 May 2001 - 03:25 AM

If you look in the java api documentation, you will see that getWidth() has only been a method of component since java 1.2. Hence under IE 5.5 (which ONLY supports java 1.1) the method does not exist, hence the NoSuchMethodError.


Use getSize().width instead.

#8 warm0ng3r   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 May 2001 - 07:24 PM

Im actually having a similar problemo in my own applet using awt (no swing).

The applet works fine in applet viewer.
when i try it in a browser window, it loads up and displays the background image, but its as if its gone through init() (cos it goes through paint() once), but wont go through run() where the core logic lies (yes i know, i wouldve taken a more OO approach, but the assignments due pretty soon and i pannicked, and now the code looks like straight c), and the applet just sits still doing nothing.

it does handle action events, such as clicking on buttons and checkboxes, while in the browser, BUT it only refreshes to the new stuff added by the action when the window is scrolled down or whatever, when it should repaint in one of the timers that sends a repaint 33 times every second.

My conclusion? the threads (run, and extra timers) arent running...why?

here in castle camelot we eat ham and jam and spam alot!

#9 lilspikey   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 May 2001 - 10:06 PM

Maybe the extra thread have thrown exceptions and died. Do you get any error messages in the browsers java console?

#10 nowan   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 May 2001 - 12:26 AM

Well that''s what is happening with my applet too. It seems to go through run() just the once and that''s it. The applet works fine otherwise and responds to mouse clicks with all the right movements and displays.

#11 Chaoslab   Members   -  Reputation: 116

Like
Likes
Like

Posted 29 May 2001 - 10:58 AM

Well that''s correct! Run is called once!

declare you run like this!


public boolean applet_active = true;
public void run()
{
while(applet_active) do_main_loop();
}

private void do_main_loop()
{
blah blah blah blah.....
rubarb rubarb rubarb.....
}



:-)



#12 nowan   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 May 2001 - 10:41 PM

Well, sometimes it just takes someone to come along and state the hidden obvious Thanks a million Chaoslab, everything now hunky cool!

nowan




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS