Mario,
Java is a case sensitive language. You are getting a NullPointerException
because the getParameter call is looking for WINDOWCLASS and can't find it.
Please change the case of the param name to match that in the java class.
Hope this helps,
Joel McCarty
Mario Jorge Nunes Filipe wrote:
> Hi
>
> I'm trying to pass parameters to an applet.
>
> My html says the following :
>
> <applet code="applet_si.class" width=500 height=300>
> <PARAM NAME=windowClass VALUE=BorderWindow>
> You don't have java!!
> </applet>
>
> My applet is like this :
>
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> import javax.swing.tree.*;
> import javax.swing.event.*;
> import javax.swing.JTree;
> import javax.swing.tree.DefaultMutableTreeNode;
> import javax.swing.tree.DefaultTreeModel;
>
> public class applet_si extends javax.swing.JApplet {
>
> /** Initializes the Form */
> public applet_si() {
> initComponents ();
> }
>
> private void initComponents () {
>
> getContentPane ().setLayout (new java.awt.BorderLayout ());
>
> String windowClass = getParameter("WINDOWCLASS");
> if (windowClass == null) {
> windowClass="Nao chegou nada";
>
> }
>
> DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
> DefaultMutableTreeNode c1 = new DefaultMutableTreeNode(windowClass);
> DefaultMutableTreeNode c2 = new DefaultMutableTreeNode("Child2");
> DefaultMutableTreeNode gc1 = new
> DefaultMutableTreeNode("Grandchild1");
> DefaultMutableTreeNode gc2 = new
> DefaultMutableTreeNode("Grandchild2");
> DefaultMutableTreeNode ggc1 = new
> DefaultMutableTreeNode("GrandGrandChild1")
> ;
> DefaultMutableTreeNode c3 = new DefaultMutableTreeNode("Child3");
>
> root.add(c1);
> root.add(c2);
> root.add(c3);
> c1.add(gc1);
> c1.add(gc2);
> gc1.add(ggc1);
>
> DefaultTreeModel model = new DefaultTreeModel(root);
>
> jtree1 = new JTree(model);
> jtree1.setRootVisible (false);
> jtree1.setEditable (true);
>
> getContentPane().add(jtree1, "Center");
> }
> private javax.swing.JTree jtree1;
> }
>
> When i do appletviewer xpto.html i get this
>
> java.lang.NullPointerException:
> at java.applet.Applet.getParameter(Applet.java:124)
> at applet_si.initComponents(applet_si.java:21)
> at applet_si.<init>(applet_si.java:14)
> at sun.applet.AppletPanel.createApplet(AppletPanel.java:456)
> at sun.applet.AppletPanel.runLoader(AppletPanel.java:392)
> at sun.applet.AppletPanel.run(AppletPanel.java:231)
> at java.lang.Thread.run(Thread.java)
>
> What am i doing wrong. The param tag and the getParameter call where
> copyed directly from the tutorial. I'm going crazy with this thing... :(
>
> Thanks
>
> Mario Filipe
> [EMAIL PROTECTED]
> http://neptuno.sc.uevora.pt/~mjnf
>
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]