小编nul*_*ull的帖子

在java中向Graphics添加textfield

有谁知道如何添加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);
Run Code Online (Sandbox Code Playgroud)

但是,尽管它显示,我无法编辑它.即使是Input.setBounds(800,250, 350,20)没有奏效.上面写的这个方法是在游戏循环中调用的.谁能帮我?

java graphics render jtextfield bufferstrategy

8
推荐指数
1
解决办法
4689
查看次数

标签 统计

bufferstrategy ×1

graphics ×1

java ×1

jtextfield ×1

render ×1