0
我在netbeans中運行此操作,它不顯示任何內容。有誰知道爲什麼NetBeans不顯示用戶界面?是因爲我使用了一個空的java文件嗎?我的代碼如下。我是netbeans和java的新手,所以任何幫助將不勝感激。Netbeans不顯示用戶界面
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();
}
}
謝謝堆!上面的代碼在我使用cmd運行時工作。所以我不知道爲什麼它不能在netbeans中工作,但歡呼! – user3359195
不客氣:-) – robson