は表示されません。ユーザーが何らかのテキストを入力できるようにテキストフィールドが必要なだけですが、JTextFieldは私のJPanelでは表示されません。ボタンとラベルの両方が問題なく表示されます。どのようにこの問題を解決する上で助けをはるかに感謝します。ここに私のコードです。JPanelのは、私は簡単なプログラムのためのGUIを作成しようとしているのJTextField
public static void main(String[] args) {
JFrame frame = new JFrame("David's cube program!");
frame.setVisible(true);
frame.setSize(800,350); // i used some code from
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.add(panel1);
panel1.setLayout(null);
JButton button = new JButton("Click to display moves");
panel1.add(button);
button.setLocation(150, 20);
button.setSize(200,50);
button.addActionListener (new Button1Action());
JLabel textArea = new JLabel("Click the button to run moves!");
panel1.add(textArea);
textArea.setLocation(15, 40);
textArea.setSize(600, 100);
textBox = new JTextField(20);
textBox.setFont(textBox.getFont().deriveFont(20f));
textBox.setLocation(15, 180);
textBox.addActionListener (new TextAction());
textBox.setVisible(true);
panel1.add(textBox);
JButton button2 = new JButton("Click to change file path");
panel1.add(button2);
button2.setLocation(150, 160);
button2.setSize(200,50);
button2.addActionListener (new Button2Action());
JLabel textArea2 = new JLabel("the textfield should be just above me");
panel1.add(textArea2);
textArea2.setLocation(15, 200);
textArea2.setSize(600, 100);
}
パネルの '検証/再検証 'を試みましたか?'再描画'ですか? – Idos
** end ** – Idos
で 'frame.setVisible(true);'を呼び出すと 'textBox'にサイズを指定していません – Berger