Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 6th, 2005, 8:55 PM   #1
Dark Flare Knight
Hobbyist Programmer
 
Join Date: Mar 2005
Location: Canada
Posts: 113
Rep Power: 4 Dark Flare Knight is on a distinguished road
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
Dark Flare Knight is offline   Reply With Quote
Old Jul 6th, 2005, 9:29 PM   #2
Dark Flare Knight
Hobbyist Programmer
 
Join Date: Mar 2005
Location: Canada
Posts: 113
Rep Power: 4 Dark Flare Knight is on a distinguished road
Nvm, I got it now.
Dark Flare Knight is offline   Reply With Quote
Old Jul 6th, 2005, 10:27 PM   #3
Dark Flare Knight
Hobbyist Programmer
 
Join Date: Mar 2005
Location: Canada
Posts: 113
Rep Power: 4 Dark Flare Knight is on a distinguished road
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.
Dark Flare Knight is offline   Reply With Quote
Old Jul 7th, 2005, 8:48 AM   #4
Easter Bunny
Programmer
 
Easter Bunny's Avatar
 
Join Date: Mar 2005
Location: different places. constantly on the run.
Posts: 57
Rep Power: 4 Easter Bunny is on a distinguished road
this is console window stuff?
__________________
There's got to be more to life than being really, really
ridiculously good looking
Easter Bunny is offline   Reply With Quote
Old Jul 7th, 2005, 10:33 AM   #5
Dark Flare Knight
Hobbyist Programmer
 
Join Date: Mar 2005
Location: Canada
Posts: 113
Rep Power: 4 Dark Flare Knight is on a distinguished road
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.
Dark Flare Knight is offline   Reply With Quote
Old Jul 8th, 2005, 2:21 AM   #6
Easter Bunny
Programmer
 
Easter Bunny's Avatar
 
Join Date: Mar 2005
Location: different places. constantly on the run.
Posts: 57
Rep Power: 4 Easter Bunny is on a distinguished road
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
Easter Bunny is offline   Reply With Quote
Old Jul 8th, 2005, 5:04 AM   #7
HeX
Programmer
 
HeX's Avatar
 
Join Date: May 2005
Location: Kosova
Posts: 94
Rep Power: 4 HeX is on a distinguished road
Send a message via MSN to HeX
you can do that with a keylistener, if y is pressed then System.out.println("Yes");
and so on..
__________________
countdown++;
HeX is offline   Reply With Quote
Old Jul 8th, 2005, 7:05 AM   #8
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 406
Rep Power: 5 xavier is on a distinguished road
Send a message via Yahoo to xavier
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 !
xavier is offline   Reply With Quote
Old Jul 8th, 2005, 8:30 AM   #9
Dark Flare Knight
Hobbyist Programmer
 
Join Date: Mar 2005
Location: Canada
Posts: 113
Rep Power: 4 Dark Flare Knight is on a distinguished road
Any useful site or a tutorial that might be able to help me figure out how to use KeyListener?
Dark Flare Knight is offline   Reply With Quote
Old Jul 8th, 2005, 10:38 AM   #10
Easter Bunny
Programmer
 
Easter Bunny's Avatar
 
Join Date: Mar 2005
Location: different places. constantly on the run.
Posts: 57
Rep Power: 4 Easter Bunny is on a distinguished road
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
Easter Bunny is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:33 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC