8
有誰知道如何將JTextField
添加到圖形名稱bufferstrategy.getDrawGraphics
? Tryed痛成圖形,這樣的事情:將文本字段添加到java中的圖形
private JTextField Input = new JTextField();
BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
return;
}
final Graphics gCommands = bs.getDrawGraphics();
Graphics gCC = bs.getDrawGraphics();
Input.requestFocus();
Input.paint(gCC);
Input.setBounds(800,250, 350,20);
Input.setBorder(BorderFactory.createLineBorder(Color.BLACK, 0));
Input.setEditable(true);
Input.setBackground(getBackground());
Input.setForeground(getForeground());
Input.addKeyListener(key);
但是,儘管它已經顯示出來,我不能編輯它。即使是Input.setBounds(800,250, 350,20)
也不起作用。上面寫的這個方法,在一個gameloop中被調用。誰能幫我?
出了什麼問題?你有運行時錯誤嗎?顯示了嗎? – Frecklefoot
雖然「JTextField」不可編輯,但它顯示 – null
該類是Canvas嗎? JFrame的? – Tips48