User interface Netbeans不显示UI
我在netbeans中运行它,它没有显示任何内容。有人知道为什么netbeans不显示用户界面吗?是因为我使用的是一个空的java文件吗?我的代码如下。我是netbeans和java新手,因此如果有任何帮助,我将不胜感激User interface Netbeans不显示UI,user-interface,User Interface,我在netbeans中运行它,它没有显示任何内容。有人知道为什么netbeans不显示用户界面吗?是因为我使用的是一个空的java文件吗?我的代码如下。我是netbeans和java新手,因此如果有任何帮助,我将不胜感激 import java.awt.*; import javax.swing.*; class UserInterface extends javax.swing.JFrame { public UserInterface() { setTitle("My Fi
import java.awt.*;
import javax.swing.*;
class UserInterface extends javax.swing.JFrame {
public UserInterface() {
setTitle("My First UI");
setLayout(null);
setBounds(10,10,400,600);
Container con = getContentPane();
JLabel lblCustomerName = new JLabel("Customer Name");
JTextField txtCustomerName = new JTextField();
JButton btnOkay = new JButton("Okay");
lblCustomerName.setBounds(20,20,100,20);
txtCustomerName.setBounds(125,20,100,20);
btnOkay.setBounds(20,300,80,60);
con.add(lblCustomerName);
con.add(txtCustomerName);
con.add(btnOkay);
con.setVisible(true);
}
}
class Tester {
public static void main(String[] args) {
new UserInterface();
}
}
java代码无法显示框架 请在Tester.class中设置:
class Tester {
public static void main(String[] args) {
UserInterface ui = new UserInterface();
ui.setVisible(true);
}
}
您可以删除
con.setVisible(true)代码>来自您的用户界面。类。谢谢!上面的代码在我使用cmd运行时起作用。所以我不确定为什么它在netbeans中不起作用,但是干杯!