i am having two problems. 1st is i want to print 3 char from string. i dont want to print ontop of each other so i am doing 600*i. but this not really working.
2nd question is that if user hit 3 keys at same time than in string it will add only one and string will be full. bc user hit 3 times at same time.
full code
Code:
g.drawString(username[i], 600*i, 300);
full code
Code:
//paint method
for(int i = 0; i < username.length; i++){
g.drawString(username[i], 600*i, 300);
System.out.print(username[i]);
}
Code:
int z = 0;
String username[] = new String[3];
public void keyPressed(KeyEvent e)
{
int keys = e.getKeyCode();
username[z] = KeyEvent.getKeyText(keys);
e.consume();
}
public void keyReleased(KeyEvent e)
{
int keys = e.getKeyCode();
z++;
e.consume();
}
Comment