Ingame TextField

Hi,

I am developing my first game and in settings menu I would like to have field where player will be able to change a name. I tried with JTextField but is not working properly, it is blinking because of updating game.I also tried with setIgnoreRepaint but did not work. Can you please tell me how can I fix the problem? My code looks something like this:

private JTextField player_name;

public void init() {
        .... more code ....
        player_name= new JTextField();
        player_name.setText("Player name");
}

public void paint(Graphics g) {

if (status == GameState.settings) {
            
            g.drawImage(submenu, 0, 0, this);
            player_name.setLocation(330,250);
            player_name.setSize(150,50);
            add(player_name);
            
            g.setColor(new Color(229,241,95));
            g.drawRect(330, 400, 140, 50);
            g.drawString("BACK",340,440);
            
        }

         .... more code ....
}
}

Regards Jan

Since Swing component only needs drawn once, pause render loop when it appears.