7 Replies - 2157 Views - Last Post: 08 August 2010 - 07:42 PM Rate Topic: -----

#1 Jono20201  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 179
  • Joined: 07-July 09

Java Applet Problem [SOLVED]

Posted 07 August 2010 - 07:30 AM

Hey, I'm trying to embed a JPanel application into a html page for the first time using applet html tag. But getting a error.

The Jar file is located here: http://galacticsquad...jar/testApp.jar

Here is the error:

Quote

java.lang.reflect.InvocationTargetException
at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.0)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkExit(Unknown Source)
at javax.swing.JFrame.setDefaultCloseOperation(Unknown Source)
at testapp.Main.initComponents(Main.java:36)
at testapp.Main.<init>(Main.java:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception: java.lang.reflect.InvocationTargetException



Here is the HTML file:
<html></head><title>Java Test</title></head>
<body>
<applet code="testapp.Main.class"
      archive="jar/testApp.jar"
      width=460 height=160>
      <param name=foo value="bar">
</applet>
</body>
</html>


and the Java file is just a plain netbeans built file (JFrame) that has a JLabel in the middle.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Main.java
 *
 * Created on 07-Aug-2010, 14:07:38
 */

package testapp;

/**
 *
 * @author Jonathan
 */
public class Main extends javax.swing.JFrame {

    /** Creates new form Main */
    public Main() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("test");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(259, 259, 259)
                .addComponent(jLabel1)
                .addContainerGap(340, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(169, 169, 169)
                .addComponent(jLabel1)
                .addContainerGap(213, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Main().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JLabel jLabel1;
    // End of variables declaration                   

}


This post has been edited by Jono20201: 07 August 2010 - 09:33 AM


Is This A Good Question/Topic? -1
  • +

Replies To: Java Applet Problem [SOLVED]

#2 bcranger  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 252
  • View blog
  • Posts: 1,199
  • Joined: 01-February 10

Re: Java Applet Problem [SOLVED]

Posted 07 August 2010 - 08:24 AM

View PostJono20201, on 07 August 2010 - 06:30 AM, said:

and the Java file is just a plain netbeans built file (JFrame) that has a JLabel in the middle.

There's your problem. An applet has to extend the Applet class...you cannot make a JFrame an applet -.-

Next time, please paste your code in code tags so we can easily read it.

And nobody at DIC will waste time trying to read GUI Generator code as it is cumbersome and hard to understand. If you want help here, you will write your GUIs using Swing with your hands :)
Was This Post Helpful? 2
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10461
  • View blog
  • Posts: 38,766
  • Joined: 27-December 08

Re: Java Applet Problem [SOLVED]

Posted 07 August 2010 - 08:24 AM

Added code tags. With over 130 posts, you should know the rules. Please post your code using code tags, like so: :code:.
Was This Post Helpful? 0
  • +
  • -

#4 Jono20201  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 179
  • Joined: 07-July 09

Re: Java Applet Problem [SOLVED]

Posted 07 August 2010 - 08:55 AM

Thanks Guys.

Sorry, at least i posted in quote tags? I don't post often anymore, try not to do it again. :dontgetit:
Was This Post Helpful? 0
  • +
  • -

#5 Guest_James Kent*


Reputation:

Re: Java Applet Problem [SOLVED]

Posted 07 August 2010 - 11:14 AM

View Postmacosxnerd101, on 07 August 2010 - 07:24 AM, said:

Added code tags. With over 130 posts, you should know the rules. Please post your code using code tags, like so: :code:.


Alright mate, don't drop your balls! Who do you think you are, D.I.C lead administrator or something? Next time we do something wrong, we must bow down to you and say sorry yeah?
Was This Post Helpful? -3

#6 bcranger  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 252
  • View blog
  • Posts: 1,199
  • Joined: 01-February 10

Re: Java Applet Problem [SOLVED]

Posted 07 August 2010 - 11:17 AM

View PostJames Kent, on 07 August 2010 - 10:14 AM, said:

View Postmacosxnerd101, on 07 August 2010 - 07:24 AM, said:

Added code tags. With over 130 posts, you should know the rules. Please post your code using code tags, like so: :code:.


Alright mate, don't drop your balls! Who do you think you are, D.I.C lead administrator or something? Next time we do something wrong, we must bow down to you and say sorry yeah?

Actually, he is a moderator. And that's besides the point. He never asked you to say sorry. He asked you to "please" post with code tags. He is just trying to help you as nobody will look at code not in code tags.

And it is kind of rude to jump in the middle of a thread saying your worthless rage when your not even the OP he was talking to.

This post has been edited by bcranger: 07 August 2010 - 11:18 AM

Was This Post Helpful? 0
  • +
  • -

#7 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10461
  • View blog
  • Posts: 38,766
  • Joined: 27-December 08

Re: Java Applet Problem [SOLVED]

Posted 07 August 2010 - 02:08 PM

View PostJames Kent, on 07 August 2010 - 02:14 PM, said:

View Postmacosxnerd101, on 07 August 2010 - 07:24 AM, said:

Added code tags. With over 130 posts, you should know the rules. Please post your code using code tags, like so: :code:.


Alright mate, don't drop your balls! Who do you think you are, D.I.C lead administrator or something? Next time we do something wrong, we must bow down to you and say sorry yeah?

The rules do state that code should be posted within code tags, as it is very hard to read unformatted code not within code tags, causing fewer members to respond and help. As a moderator, part of my responsibilities include adding code tags and enforcing the rules. If you wish to further discuss the rules or roles of the moderation team, the Site Feedback and Site Questions and Support forums are the places to do such.
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8328
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Java Applet Problem [SOLVED]

Posted 08 August 2010 - 07:42 PM

testapp and testApp are not the same
all this stuff is case sensitive
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1