有谁知道如何添加JTextField
到图形名称bufferstrategy.getDrawGraphics
?试图将其绘制成图形,如下所示:
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)
没有工作。上面写的这个方法,在游戏循环中被调用。谁能帮我?