Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Text in JtextField is not selecting.

 
Bal Sharma
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There:
I have following code for JtextField on my GUI.

I see text field with text "Enter Seat Here" but text is not selected at all. Am I missing anything here? Any response in this regard highly appreciated. Thanks - Bal

[This message has been edited by Bal Sharma (edited December 20, 2001).]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JavaDoc I found this
"selectAll
public void selectAll()
Selects all the text in the TextComponent. Does nothing on a null or empty document."
The does nothing on a null or empty document, strikes me as the reason. I could be completely wrong, since I only spent 10 seconds looking for a solution, but it really hit my spider senses
Mark

 
Bal Sharma
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Enter Seat Here" default text is in the text field. It should not treat as null or empty document. I will try getText() method and look at this what I'm gonna get.
Thanks Mark, -Bal
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doh!. I forgot that the Enter Seats Here text was in the textfield.
How about simply placing a JLabel to the left of the JTextfield saying "Number of Passengers", or "Number To Book", and no text in the JTextfield. That's what I did.
Although I also wrote code to blank out the JTextfield, if the user had entered a number, but then changed their selection in the JTable to another flight.
Mark
 
Bal Sharma
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark for your input. I got it after several hours work. Solution is very simple. I learn everything hard way that is my luck. If more than one components are listening event then must have focus for input field. I think we wanted to draw attention of input field to select text.
inputField.requestFocus();
inputField.selectAll();
Now all text is selected.
I got stuck in Search and Book Flight button event. My problem is in the table not in button or button event. I will post it tomorrow in a separate thread if I could not solve it. If you are around please look at it throw some light. I know your home land is now SCWCD Forum; right! My SCWCD passing story is there. Do not forget to read that? It tells you how did I feel SCWCD?
-Bal
 
Anurag Mishra
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Congratulation's Mark
It was really a great score.Plz tell me something about essay exam and what is the procedure to get registered with it. Is it after completion of my project i have to buy a voucher, or how the sun company will let me know that my assignment has been approved. Plz help me out about the whole procedure. As Iam from India so i don't have so much details regarding this.
Congratulation's Once Again
Anurag Mishra
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anurag: After you have completed the project, and have uploaded at the website. You then call SunEd to get a voucher for the Essay Exam, which you then call the testing company, and book a date and place to take the essay.
Don't worry about the essay exam, it is simple, and no problem as long as you did your own coding on the project. It simply asks you what you did on your assignment in certain areas, like did you chose Serialization or RMI.
Good Luck
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic