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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| 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