:私は、コードを実行すると、JLabelのが表示されないたoccuringたSwingクラス、異例のJLabelのappearence
public class QuestionFour extends JFrame {
private JTextArea txta1;
private JTextField txt1;
private JButton btnSort;
private JButton btnShuffle;
private JButton btnReverse;
private JPanel pnl1;
private JLabel lbl1;
private LinkedList linkedList;
public QuestionFour() {
super();
this.setLocationRelativeTo(null);
this.setSize(500, 200);
this.setVisible(true);
this.setLayout(new FlowLayout());
txt1 = new JTextField(); // 1
lbl1 = new JLabel("Enter a number: "); // 2
this.add(lbl1);
}
public static void main(String args[]) {
QuestionFour ob = new QuestionFour();
}
}
問題は、私の場合1行目をコメントとしてコメントするとJLabelが表示されますが、TextFieldをインスタンス化するだけでJFrameには追加しないので、私は奇妙に思っています。
誰かが私にこれを説明できますか?