![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Mar 2005
Location: Canada
Posts: 113
Rep Power: 4
![]() |
Enter
I want to ask the user their name and validate the name so the user only enters letters, small or capital. How can i do that?
EDIT Wrong Title. :p Last edited by Dark Flare Knight; Jul 6th, 2005 at 8:57 PM. Reason: Wrong Title |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Mar 2005
Location: Canada
Posts: 113
Rep Power: 4
![]() |
Nvm, I got it now.
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Mar 2005
Location: Canada
Posts: 113
Rep Power: 4
![]() |
Well, i've got another question. I am using a char to ask user to answer a question in yes or no. If the user enters y or n, i want to show the entire word Yes or No before the user can type it. How can i do that?
Btw, i couldn't edit the previous posts so i had to post again. |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Mar 2005
Location: different places. constantly on the run.
Posts: 57
Rep Power: 4
![]() |
this is console window stuff?
__________________
There's got to be more to life than being really, really ridiculously good looking |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Mar 2005
Location: Canada
Posts: 113
Rep Power: 4
![]() |
not sure what u mean by that. I want to print Yes on the screen and wait for the user to press enter if the user presses y or print No on the screen and wait for the user to press enter if the user presses n.
|
|
|
|
|
|
#6 |
|
Programmer
Join Date: Mar 2005
Location: different places. constantly on the run.
Posts: 57
Rep Power: 4
![]() |
ahhh... ok, i get it. it's the dos screen thingy(text only, no buttons, textboxes, etc).
i'll have to go do some research on that. be back by the end of the day with an answer...
__________________
There's got to be more to life than being really, really ridiculously good looking |
|
|
|
|
|
#7 |
|
Programmer
|
you can do that with a keylistener, if y is pressed then System.out.println("Yes");
and so on..
__________________
countdown++; |
|
|
|
|
|
#8 |
|
Professional Programmer
|
I don't think you can do that in the console. It always waits for an enter at the end of the line, tu execute a command.
So, i don't think you can do what you want.
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Mar 2005
Location: Canada
Posts: 113
Rep Power: 4
![]() |
Any useful site or a tutorial that might be able to help me figure out how to use KeyListener?
|
|
|
|
|
|
#10 |
|
Programmer
Join Date: Mar 2005
Location: different places. constantly on the run.
Posts: 57
Rep Power: 4
![]() |
i've got it!!! if you can't win, cheat!!
![]() create a jframe, but make it invisible [setVisible(false)] and then add a keylistener to it. check sun's tutorial. just quickly got this. didn't go through it, but i'm sure you can find something there, but if you don't, then let me know. http://java.sun.com/docs/books/tutor...ylistener.html what will happen then, is the user will read what the console window and then do whatever he wants. the jframe will be taking in what he enters, and then you'll put what he types on the console window with System.out.print( characterEntered ). you can now take a y that he enters and turn it into a "YES"!!! WOW!!! i am so freaking amazing i scare myself! i'll go play with the idea and see if i can get it to work.
__________________
There's got to be more to life than being really, really ridiculously good looking |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|