Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java AWT applet  RSS feed

 
VarunS Singh
Ranch Hand
Posts: 31
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The output in applet window is :

Font Name is: Not Found
Font Size is:-1
Leading:0.0
Active: false


Why does it goes in The Exception in every block of code?
 
Stephan van Hulst
Saloon Keeper
Posts: 7797
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because apparently whatever you're passing as fontSize, it's not an integer.
 
Tim Moores
Saloon Keeper
Posts: 3881
91
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works fine for me using Java 8 on OS X. Offhand, I can't think of a reason why it wouldn't work elsewhere, since appletviewer would presumably work the same on all platforms.

As an aside, you should get in the habit of using double quotes around both names and values: <param name="fontName" value="Courier"> rather than <param name = fontName value = Courier>.

And, of course, applets are completely obsolete by now, so you should switch to learning standalone applications (or Java Web Start applications) instead, using JavaFX or Swing rather than AWT.
Screen-Shot-2017-04-10-at-09.49.46.png
[Thumbnail for Screen-Shot-2017-04-10-at-09.49.46.png]
 
Tony Docherty
Bartender
Posts: 3268
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect Tim is correct and it's because of the missing quotes.

Whilst Applets should work the same on all platforms the html that kicks off the Applet is read and processed by the browser and it may be that the browser you are using doesn't understand the param tag with missing quotes whereas Tim's browser has made some correct assumptions about what you intended to write. Can you make the changes he suggested and let us know if that has fixed the problem.

BTW Tim is also correct about Applets being obsolete, I suggest you don't spend too much time learning how to write code for them.
 
Tim Moores
Saloon Keeper
Posts: 3881
91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect Tim is correct and it's because of the missing quotes.

Actually, I tried the unchanged source code and it worked fine for me. So I can't even think of something to try instead.
 
Tony Docherty
Bartender
Posts: 3268
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you use AppletViewer or your browser?
 
Tony Docherty
Bartender
Posts: 3268
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose there is always the unlikely possibility that the OP's system doesn't have the "Courier" font installed.
 
Tim Moores
Saloon Keeper
Posts: 3881
91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used appletviewer via "appletviewer Parameter_Passing.java".
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OP's system doesn't have the "Courier" font installed.

The code doesn't use the values of the parameters for anything but to display some text in the window.
This works for me using appletviewer,  ie  the values are read and shown in the window:
 
VarunS Singh
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed as you suggested , but still not working....
 
VarunS Singh
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Netbeans, and as these Html code is written as comment , does it really matters , regarding the double coutes?
 
Paul Clapham
Sheriff
Posts: 22471
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It never hurts to use well-formed HTML. And since your error messages from the original post tell me that your applet parameters are being ignored, it might be that using sloppy HTML is a problem. It might also be that something else is causing Netbeans to fail to notice the parameters.
 
Tim Moores
Saloon Keeper
Posts: 3881
91
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe NetBeans works differently than appletviewer - did you try that one?
 
VarunS Singh
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are  rights guys it is actually working ok in Appletviewer
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!