因此,对于一项任务,我必须制作一个小的 Java 小程序并将其显示在网页上。它在 NetBeans 中构建得很好,但是当我尝试在网页中运行它时,它显示为灰色,如下所示:
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")
那么有什么问题呢?