【发布时间】:2019-12-02 09:53:58
【问题描述】:
我最近在使用 netbeans 时遇到了很多麻烦,我现在使用的是可移植版本(Apache NetBeans IDE 11.2),带有 JDK 13.0.1,每当我尝试运行最简单的 JFrame 时,它们都会因此错误而崩溃:
C:\Users\banhi\AppData\Local\NetBeans\Cache\11.2\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\banhi\AppData\Local\NetBeans\Cache\11.2\executor-snippets\run.xml:68: Java returned: -1073740771
BUILD FAILED (total time: 3 seconds)
我所做的只是创建一个没有 main 的应用程序,然后在默认打包中创建一个 JFrame(只是为了测试)并添加一个按钮:
public class JFnis extends javax.swing.JFrame {
public JFnis() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("jButton1");
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(117, 117, 117)
.addComponent(jButton1)
.addContainerGap(210, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(115, 115, 115)
.addComponent(jButton1)
.addContainerGap(162, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
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 ex) {
java.util.logging.Logger.getLogger(JFnis.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(JFnis.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(JFnis.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(JFnis.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JFnis().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
// End of variables declaration
}
- .java 类工作正常
- Source/Binary 和 java 平台都设置为 JDK 13
- 我可以很好地清理和构建项目
【问题讨论】:
标签: java swing netbeans jframe portability