作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Netbeans,并且之前已经启动并运行过它,但我弄乱了一些代码,现在它不是了。有人可以告诉我我做错了什么吗?
public class OrderGUI extends javax.swing.JFrame {
ArrayList orders = new ArrayList<>();
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(OrderGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(OrderGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(OrderGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(OrderGUI.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() {
OrderGUI gui = new OrderGUI();
gui.setVisible(true);
gui.setTitle("Flexbox Order System");
gui.setResizable(false);
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
});
}
}
最佳答案
您只是忘记设置大小:它在我的系统上运行良好。在这里,我为你清理了一些。
package developerToolsNotForDeployment;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
public class OrderGUI extends javax.swing.JFrame {
ArrayList orders = new ArrayList<>();
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
OrderGUI gui = new OrderGUI();
gui.setTitle("Flexbox Order System");
gui.setResizable(false);
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gui.setSize(new Dimension(400,400));
gui.setVisible(true);
}
});
}
关于java - 如何让 JFrame 显示我的 GUI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27158148/
我是一名优秀的程序员,十分优秀!