Java JApplet只在网页上显示灰色

时间:2013-06-08 11:07:13

标签: java browser netbeans applet japplet

因此,对于作业,我必须制作一个小Java小程序并将其显示在网页上。它在NetBeans中构建得很好,但是当我尝试在网页中运行它时,它显示为灰色,如下所示: enter image description here

import java.awt.GridBagConstraints;
    import java.lang.reflect.InvocationTargetException;
    import javax.swing.JButton;
    import javax.swing.JTextArea;

    public class PlanZajecJavaProjektApplet extends javax.swing.JApplet {

        /**
         * Initializes the applet PlanZajecJavaProjektApplet
         */
        public static int licznikTextFields = 0;
        int dzienLekcji;
        int godzinaLekcji;
        int ileGodzinLekcji;
        private GridBagConstraints gridBagConstraints;
        private JButton button;

        @Override
        public void init() {
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(PlanZajecJavaProjektApplet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>

            /* Create and display the applet */
            try {
                java.awt.EventQueue.invokeAndWait(new Runnable() {
                    @Override
                    public void run() {
                        initComponents();

                    }
                });
            } catch (InterruptedException | InvocationTargetException ex) {
            }
        }

        /**
         * This method is called from within the init() method to initialize the
         * form. WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")

那有什么不对?

1 个答案:

答案 0 :(得分:0)

如堆栈跟踪所示,您的applet看起来没有它想要做的事情的权限。

第51行

中的代码中删除以下行:

setStub(null);