This site requires JavaScript, please enable it in your browser!
Greenfoot back
henrYoda
henrYoda wrote ...

2013/4/28

Getting user input

henrYoda henrYoda

2013/4/28

#
Hi, I recently published my game, called The robots, and It has a scoreboard. I was wondering how I can prompt the user to choose a user name, so that it shows up on the score board. The source code is available for download if you click on my game. Thanks for reading, -henrYoda
danpost danpost

2013/4/29

#
Users already have user names in Greenfoot (if they are logged on); and their user names are available through the UserInfo class methods.
if (UserInfo.storageIsAvailable()) String user = UserInfo.getMyInfo().getUserName();
henrYoda henrYoda

2013/4/29

#
I know, but is there a way to ask them to type in a username?
danpost danpost

2013/4/29

#
You can use JOptionPane objects to get user input; or you can program it yourself to better control how it works. See the Java tutorials on how to use JOptionPanes.
You need to login to post a reply.