1 2 Previous Next 15 Replies Latest reply on Dec 16, 2009 12:53 AM by 793415

    Netbeans Japplet Problem

    801574
      Ok, so i wrote a japplet that I would like to incorporate into a webpage. The problem is, I have been getting an "Applet xxxxx notinited" error when I run it in a html using this code:
      <html>
      <head>
      <title>TEST</title>
      </head>
      
      <!-- Background white, links blue (unvisited), navy (visited), red
      (active) -->
      <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
      vlink="#000080" alink="#FF0000">
      
      <applet code="NewJApplet.class" 
      width="100%" height="95%"> </applet>
      
      </html>
      however, if the applet is just an applet, and not a japplet, the above code works and the applet loads properly. Now this is what I would do if I could, but unfortunately, netbeans autogenerates some code that uses swing, namely a getContentPane() command that wont work if I convert the japplet to an applet. So, I ran the applet viewer on index.html in the terminal, and this is what I get:

      Exception in thread "main" java.util.MissingResourceException: Can't find resource for bundle sun.applet.resources.MsgAppletViewer, key appletpanel.badattribute.exception
      at java.util.ResourceBundle.getObject(ResourceBundle.java:325)
      at java.util.ResourceBundle.getString(ResourceBundle.java:285)
      at sun.applet.AppletMessageHandler.getMessage(AppletMessageHandler.java:39)
      at sun.applet.AppletPanel.showAppletStatus(AppletPanel.java:911)
      at sun.applet.AppletPanel.init(AppletPanel.java:199)
      at sun.applet.AppletViewer.<init>(AppletViewer.java:177)
      at sun.applet.StdAppletViewerFactory.createAppletViewer(AppletViewer.java:82)
      at sun.applet.AppletViewer.parse(AppletViewer.java:1122)
      at sun.applet.AppletViewer.parse(AppletViewer.java:1056)
      at sun.applet.Main.run(Main.java:138)
      at sun.applet.Main.main(Main.java:80)


      Any ideas on what I could try next? or maybe how to make a getContentPane() command work if the class extends Applet instead of JApplet?
      Thanks beforehand.
        • 1. Re: Netbeans Japplet Problem
          801574
          I thought the problem had something to do with the fact I was using Netbeans forms to design the applet, but i just tested it with a class that extends applet, and it seems to work. It seems like the problem is just the JApplet.....

          EDIT: Wow, never mind, an applet built using the netbeans forms doesnt work.... maybe thats the problem?

          Edited by: Young_one on Dec 14, 2009 3:22 PM
          • 2. Re: Netbeans Japplet Problem
            793415
            Young_one wrote:
            Ok, so i wrote a japplet that I would like to incorporate into a webpage.
            URL of the web page?
            ..how to make a getContentPane() command work if the class extends Applet instead of JApple
            I have a JApplet at [http://pscode.org/prop/?prop=java.version].

            Visit that URL and report back:
            1) Does the applet work for you?
            2) If so, what information does it provide in the JTable.
            • 3. Re: Netbeans Japplet Problem
              801574
              Hey Andrew,

              I cant give you a url, since Im just testing the applet through my local network right now. I visited the url you sent me, and the applet did not load. :( also, I found today that anything I make using the forms of netbeans cant be "inited", while other applets work. Is your JApplet done using the visual design portion of netbeans? Thanks.
              • 4. Re: Netbeans Japplet Problem
                793415
                Young_one wrote:
                ..I cant give you a url, since Im just testing the applet through my local network right now.
                So upload it to an URL we can see! (Or to put that another way "Use some initiative".)
                ..I visited the url you sent me, and the applet did not load.
                What was the exact error you got?
                ..:( also, I found today that anything I make using the forms of netbeans cant be "inited", while other applets work. Is your JApplet done using the visual design portion of netbeans?
                It is done using Java, nothing to do with Netbeans. Further, the applet was made to be compatible with Java 1.4+.
                • 5. Re: Netbeans Japplet Problem
                  801574
                  I will upload it shortly, if all goes as planned. As for the error I got, the applet viewer gave me this:

                  java.lang.NoClassDefFoundError: netscape/javascript/JSObject
                  at org.pscode.tool.applet.Wrapplet.initializeJSObject(Wrapplet.java:410)
                  at org.pscode.tool.applet.Wrapplet.init(Wrapplet.java:111)
                  at sun.applet.AppletPanel.run(AppletPanel.java:380)
                  at java.lang.Thread.run(Thread.java:613)
                  • 6. Re: Netbeans Japplet Problem
                    793415
                    Young_one wrote:
                    I will upload it shortly, if all goes as planned.
                    Good work.
                    .. As for the error I got, the applet viewer gave me this:
                    AppletViewer?!? No. Run it in a browser. That applet will never work in the AppletViewer. At least, not until Sun implements a JSObject for the appletviewer - which I expect will be 'never'.

                    BTW - the applet that you are testing, are you testing it in appletviewer or a browser? If a browser, what version of what browser?
                    • 7. Re: Netbeans Japplet Problem
                      801574
                      >
                      AppletViewer?!? No. Run it in a browser. That applet will never work in the AppletViewer. At least, not until Sun implements a JSObject for the appletviewer - which I expect will be 'never'.
                      >

                      I ran it in a browser at first, and just got a applet notinited error, nothing else.

                      >
                      BTW - the applet that you are testing, are you testing it in appletviewer or a browser? If a browser, what version of what browser?
                      >

                      I've tested my applet in the applet viewer, safari 4, and in firefox 3.0.15. I don't understand why a normal applet works, but one with a bunch of swing OR awt components/functions doesn't? Since thats all the netbeans forms do: make a function that sets up your GUI.
                      • 8. Re: Netbeans Japplet Problem
                        793415
                        Young_one wrote:
                        >
                        AppletViewer?!? No. Run it in a browser. That applet will never work in the AppletViewer. At least, not until Sun implements a JSObject for the appletviewer - which I expect will be 'never'.
                        >

                        I ran it in a browser at first, and just got a applet notinited error, nothing else.
                        If you are to successfully debug applets, it is necessary to take your information sources to 'the next level'.. (1)
                        >
                        BTW - the applet that you are testing, are you testing it in appletviewer or a browser? If a browser, what version of what browser?
                        >

                        I've tested my applet in the applet viewer, safari 4,..
                        Huhh. So you are testing on Mac OS? If so, what version? (1)
                        ..and in firefox 3.0.15. I don't understand why a normal applet works, but one with a bunch of swing OR awt components/functions doesn't? Since thats all the netbeans forms do: make a function that sets up your GUI.
                        1) I suspect that 'Java versions' has something to do with this problem.

                        The link that I put earlier was intended to discover what version of the JRE the browser(s) are configured to use. It surprises me that you get a failure for that page, since although the 'properties' applet is designed for Java 1.4+, it in turn is loaded by Wrapplet, which is compatible with Java 1.1. One of Wrapplet's tasks is to check that the browser is running the minimum major version of Java specified in the applet parameters, before loading & displaying the second applet. If the minimum version is greater than what is used by the browser, Wrapplet will redirect the user to another page.

                        So I am surprised it fails, but I need more information to understand why it fails. Which brings me to the Java Console, and Macintosh.

                        On Windows and Linux, if an applet breaks completely, there is a white space in the web page where the applet should be, and it has a message to the effect 'applet broken: click for details'. By clicking that area, the Java Console should appear.

                        For applets that throw exceptions after loading, it is trickier to get the console. There used to be a menu item in the browser to view the Java Console, but of recent times that menu item has disappeared, and instead the Java Console visibility is controlled by the Java Control Panel. To get the Java Console to appear, open the JCP, go to the Advanced tab, Java Console leaf, and select Show Console. You might need to restart the browser for it to take effect.

                        I am not sure how much of the above is correct for Mac. (it'd be useful if you can tell me the Mac. details), but you need to figure how to get the console to show. Without the console, we are trying to debug this with 'one arm tied behind our back'.
                        --------------
                        BTW - did you decide to do an applet because you thought applets were 'simple'? If so, I chuckle.. ;)
                        • 9. Re: Netbeans Japplet Problem
                          801574
                          >
                          Huhh. So you are testing on Mac OS? If so, what version? (1)
                          >

                          Im running Mac OSX 10.5.8.

                          I know how to access the java console in mac, and I have been doing it, but there are no errors that appear. The only things I got where in the firefox error console, where i got the following:

                          Warning: Unknown property 'zoom'. Declaration dropped.
                          Source File: http://www.google.ca/firefox?client=firefox-a&rls=org.mozilla:en-US:official
                          Line: 1

                          Error: Warning: unrecognized command line flag -foreground
                          Source File: file:///Applications/Firefox.app/Contents/MacOS/components/nsBrowserContentHandler.js
                          Line: 713

                          But both browsers showed no errors in the java console :( maybe you can begin to see why I ran the applet viewer on it?

                          I just discovered something interesting. If I go to the link you gave me in firefox instead of safari, I get another error: java.lang.UnsupportedClassVersionError: Bad version number in .class file
                          and a whole bunch of errors pop up in the error console. Does that shed any light on the situation?

                          Also, I didn't choose to make an applet cause it was easy haha, I'm doing a project for work that requires some basic web site, and I've done a few applets before, I've just never had this problem.
                          • 10. Re: Netbeans Japplet Problem
                            801574
                            ok so, I think I found what the problem is, If i comment out this code, the applet loads properly:
                            private void initComponents() {
                            
                                    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
                                    this.setLayout(layout);
                                    layout.setHorizontalGroup(
                                        layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(0, 1502, Short.MAX_VALUE)
                                    );
                                    layout.setVerticalGroup(
                                        layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(0, 846, Short.MAX_VALUE)
                                    );
                            This is the code that netbeans autogenerated in my applet......

                            after some more testing, I've discovered that these 2 commands are the ones causing the init problems, even though the function they are in is not even called:
                                    layout.setHorizontalGroup(
                                        layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(0, 1502, Short.MAX_VALUE)
                                    );
                                    layout.setVerticalGroup(
                                        layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(0, 846, Short.MAX_VALUE)
                                    );
                            If those are commented out, even though they are in a function that Isn't even called, the applet loads.

                            Now I am truly lost, the applet works in netbeans, but if I try to open it in a browser with those 2 commands uncommented, the applet does not "init".

                            Any explanation of this would be greatly appreciated.

                            Thanks.

                            EDIT: After some more testing, I've discovered that the browser just doesnt like the org.* stuff, even though netbeans autogenerates some org.jdesktop stuff and some org.netbeans stuff. Anyone have any idea what this is all about?

                            Edited by: Young_one on Dec 15, 2009 10:55 AM
                            • 11. Re: Netbeans Japplet Problem
                              793415
                              Young_one wrote:
                              ok so, I think I found what the problem is, If i comment out this code, the applet loads properly:
                              ...
                              org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
                              ... 
                              Aha!
                              Any explanation of this would be greatly appreciated.
                              Check the [JavaDocs for GroupLayout|http://java.sun.com/javase/6/docs/api/javax/swing/GroupLayout.html], the @since tag indicates that the class was introduced in 1.6. The browsers of your MacOS are apparently not running 1.6.
                              • 12. Re: Netbeans Japplet Problem
                                801574
                                Well, I found a workaround - Just use the null layout instead of free design :P This means that GroupLayout isn't used, and hence, no more problem. Thanks for all your help :D

                                On a completely unrelated note, how do you get rid of the little screen flicker that happens the first time you push a button in an applet? Any help is appreciated.

                                Thanks again for all your help Andrew. :)

                                cheers.
                                • 13. Re: Netbeans Japplet Problem
                                  793415
                                  Young_one wrote:
                                  Well, I found a workaround - Just use the null layout instead of free design ..
                                  That is a very broken 'work-around'.

                                  Read from the start to the end of:
                                  [http://forums.sun.com/thread.jspa?threadID=5420311] on Netbeans.
                                  [http://forums.sun.com/thread.jspa?threadID=5411066] on null layout.
                                  • 14. Re: Netbeans Japplet Problem
                                    801574
                                    Hmmm ok, so I read those,

                                    If I cant do that then what should I do? I looked at the GroupLayout class, and I'm not sure what to make of it.... should I be trying to import that into my java code? If so, then how? :S
                                    1 2 Previous Next