27.04.2013 Views

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Applets<br />

Anyone have any ideas what is going wrong?<br />

Answer: The parseDouble method was only added to <strong>Java</strong> in JDK 1.2<br />

Browsers typically only support <strong>Java</strong> 1.1<br />

If you have the JRE installed, you can run <strong>Java</strong> 1.2 applets. But you must also change the HTML<br />

code that embeds the applet. Check javasoft.com. I believe they have a program which will<br />

automatically change the tag to and add whatever else is needed. It's been a<br />

while since I've done applets but I do remember running across a similar problem.<br />

Q: In my applet I have a bunch of gif's in my JAR file. When I try to access a gif using:<br />

Image img = getImage(getCodeBase(), "image.gif");<br />

everything works fine under Microsoft Internet Explorer but it does not under Netscape and<br />

appletviewer. Of course I do not have any gifs in my CodeBase directory on server.<br />

Any idea why?????<br />

Answer: Because this is not how you access resources in a Jar file. You need to use<br />

getResourceAsStream if you want to access GIFs from Netscape. Look at:<br />

http://developer.iplanet.com/docs/technote/java/getresource/getresource.html<br />

for example code. This same code will work in Sun's Appletviewer.<br />

--<br />

David Risner<br />

http://david.risner.org/<br />

Q: How do I get JVM version in Internet Explorer?<br />

Q: When you open the <strong>Java</strong> Console through internet explorer, it prints the following useful line at the<br />

top:<br />

Microsoft (R) VM for <strong>Java</strong>, 5.0 Release 5.0.0.3318<br />

We would like to be able to obtain the above String (or atleast the 5.0.0.3318 part of it) through a <strong>Java</strong><br />

Applet / <strong>Java</strong>script at runtime.<br />

Does anyone know of any handy methods that allow access to this String ? I've looked in all the<br />

System.properties, but it wasn't there. Is it stored in the user's registry anywhere ?<br />

Answer: just for Microsoft't VM!<br />

try :<br />

class test{<br />

public static void main(String[] args){<br />

String build;<br />

build=com.ms.util.SystemVersionManager.getVMVersion().getProperty ("BuildIncrement");<br />

System.out.println("Using build "+build);<br />

}<br />

}<br />

Real Gagnon from Quebec, Canada<br />

* Looking for code code snippets ? Visit Real's How-to<br />

* http://www.rgagnon.com/howto.html<br />

Q: I wonder if there is a way to find out if a button in an applet has been clicked, no matter which<br />

of the buttons in an applet it might be.<br />

Of course I can write, with a particular button (if event.target==button1) but maybe there is a syntax<br />

file:///F|/350_t/350_tips/applets.htm (5 of 10) [2002-02-27 21:17:49]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!