Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1520 > unrolled thread
| Started by | "ryanoasis" <ryanoasis@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:33 +0000 |
| Last post | 2011-04-27 15:34 +0000 |
| Articles | 6 — 3 participants |
Back to article view | Back to comp.lang.java.gui
japplet param "ryanoasis" <ryanoasis@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
Re: japplet param "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
Re: japplet param "Tom Hawtin" <tom.hawtin@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
Re: japplet param "ryanoasis" <ryanoasis@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: japplet param "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: japplet param "ryanoasis" <ryanoasis@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
| From | "ryanoasis" <ryanoasis@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:33 +0000 |
| Subject | japplet param |
| Message-ID | <1177349496.571185.305090@y80g2000hsf.googlegroups.com> |
To: comp.lang.java.gui
I am new to Java applets and therefore japplets as well.
I am working on a project that we want to get the params from the page
the applet tag is on. I have looked at
the various examples and they are not working for the application I am
working on however when I make my own
simple sample it works just fine.
This is the error I get when trying it in the project:
java.lang.NullPointerException
at java.applet.Applet.getParameter(Unknown Source)
I have read that the getParameter call should be in init and also in
the default constructor. This doesnt
seem to work however, I have tried the call in many other methods and
also calling it from a seperate class.
String s ="initial";
s = getParameter("asdf");
<param name="asdf" value="hi">
Thanks.
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:33 +0000 |
| Message-ID | <712752153d209@uwe> |
| In reply to | #1520 |
To: comp.lang.java.gui ryanoasis wrote: .. >the various examples and they are not working for the application I am >working on however when I make my own >simple sample it works just fine. If your simple example works 'just fine', what is your question? -- Andrew Thompson http://www.athompson.info/andrew/ Message posted via http://www.javakb.com --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Tom Hawtin" <tom.hawtin@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:33 +0000 |
| Message-ID | <462d5ccf$0$8754$ed2619ec@ptn-nntp-reader02.plus.net> |
| In reply to | #1520 |
To: comp.lang.java.gui ryanoasis wrote: > > java.lang.NullPointerException > at java.applet.Applet.getParameter(Unknown Source) > > I have read that the getParameter call should be in init and also in > the default constructor. This doesnt Where did you read that?[1] The constructor must have completed before getParameter will work. getParameter just forwards to the AppletStub (look at the source). Because your subclass of Applet calls the no-args Applet constructor (either implicitly or explicitly), there is no (reasonable) way the applet container can set the stub before your constructors have completed. You should be able to call getParameter in the init method. [1] As a point of pedantry a default constructor is technically a synthetic constructor provided by the compiler if there are no constructors is the class' source. A constructor with no arguments is generally referred to as a "no-args constructor". Tom Hawtin --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "ryanoasis" <ryanoasis@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Message-ID | <1178727892.406859.207690@u30g2000hsc.googlegroups.com> |
| In reply to | #1522 |
To: comp.lang.java.gui Sorry I meant I read that it should be in the default constructor OR the init method. It is obvious after viewing the replies I wasn't completely clear and that is probably because I don't know much about the general workings of a Java applet at this point well enough to explain what I am trying to do. Yes apparently I didn't ask a question my apologies, I suppose in hindsight my question was what could be causing an issue with get parameters when it does work with a simple example? "A constructor with no arguments is generally referred to as a "no-args constructor". " Generally? All books that I have read have almost always called it a default constructor but thank you for the extra info. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Message-ID | <71f05f7d66328@uwe> |
| In reply to | #1605 |
To: comp.lang.java.gui ryanoasis wrote: (applet) >what could be causing an issue with get parameters when it does work >with a simple example? The HTML is the most likely culprit. Is it validated? What is the URL of the HTML/applet? Had you considered web start for launching this applet? E.G. <http://www.physci.org/jws/#jtest> (applet, but no parameters specified). -- Andrew Thompson http://www.athompson.info/andrew/ Message posted via JavaKB.com http://www.javakb.com/Uwe/Forums.aspx/java-gui/200705/1 --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "ryanoasis" <ryanoasis@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Message-ID | <1178817954.131528.31200@e51g2000hsg.googlegroups.com> |
| In reply to | #1606 |
To: comp.lang.java.gui
I will look into that.
I have found a way to get it to work (although I'm sure its less than
great):
// CLASS TO HANDLE PARAMS:
public class MAParam extends JApplet {
public static String myStatic = "init static";
public void init()
{
myStatic = getParameter("count");
}
}
// HTML:
<html>
<body>
<applet code="MAParam.class" width="0" height="0">
<param name="count" value=2 />
</applet>
<applet code="ClassIDidntWrite.class" width="800" height="550">
</applet>
</body>
</html>
// CLASS: ClassIDidntWrite
private static String PARAM;
public ClassIDidntWrite() {
PARAM = MAParam.myStatic;
System.out.println("PARAM IS: " + PARAM);
System.out.println("MyStatic IS: " + MAParam.myStatic);
...
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web