下面编写的代码仅在控制台中显示这是它为什么不显示我使用 windows builder 创建 UI 的 UI。
import javax.swing.JFrame;
public class getData extends JFrame {
JFrame frame = new JFrame();
JTextArea textArea = new JTextArea();
JTextArea textArea_1 = new JTextArea();
JTextArea textArea_2 = new JTextArea();
JLabel lblNewLabel = new JLabel("BOX");
JLabel lblPlc = new JLabel("PLC");
JLabel lblHmi = new JLabel("HMI");
JButton btnSubmit = new JButton("SUBMIT");
JButton btnExport = new JButton("EXPORT");
public getData() {
initGUI();
}
void initGUI(){
getContentPane().setLayout(null);
this.textArea.setBounds(28, 50, 105, 162);
getContentPane().add(this.textArea);
this.textArea_1.setBounds(183, 50, 105, 162);
getContentPane().add(this.textArea_1);
this.textArea_2.setBounds(319, 50, 105, 162);
getContentPane().add(this.textArea_2);
this.lblNewLabel.setFont(new Font("Times New Roman", Font.PLAIN, 13));
this.lblNewLabel.setBounds(28, 25, 46, 14);
getContentPane().add(this.lblNewLabel);
this.lblPlc.setFont(new Font("Times New Roman", Font.PLAIN, 13));
this.lblPlc.setBounds(183, 25, 46, 14);
getContentPane().add(this.lblPlc);
this.lblHmi.setFont(new Font("Times New Roman", Font.PLAIN, 13));
this.lblHmi.setBounds(317, 25, 46, 14);
getContentPane().add(this.lblHmi);
this.btnSubmit.setFont(new Font("Times New Roman", Font.PLAIN, 13));
this.btnSubmit.setBounds(22, 228, 89, 23);
getContentPane().add(this.btnSubmit);
this.btnExport.setFont(new Font("Times New Roman", Font.PLAIN, 13));
this.btnExport.setBounds(300, 228, 89, 23);
getContentPane().add(this.btnExport);
frame.setSize(500, 500);
frame.add(getContentPane());
frame.setTitle("Bar Code Scanner");
frame.setVisible(true);
}
public static void main(String[] args) {
System.out.println("This Is It");
}
}
当我将标签从源切换到设计时,它也会显示。提前致谢。