Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get variable from JTextField()

 
Ji Wang
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
I am writing a simple application.
I have
crystalPanel.add(new JLabel("Product type"));
typeField = new JTextField(5);
crystalPanel.add(typeField);
I would like to have a FINISH button to end the input.
Please let me know how to add the FINISH button to end the input from multiple JTextFields.
Thanks.
 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not quite sure what you mean by end the input. If you are talking about getting the an action to happen after you hit a button then you need to read up on events. Look here.. if I'm wrong, please state it a bit clearer
http://developer.java.sun.com/developer/Books/swing/
or try here
http://java.sun.com/docs/books/tutorial/uiswing/events/
-Regards
Dale
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
First, someone (like me) is going to give you a hard time about not following the Naming Policy here at JavaRanch. So, you might want to re-register and change your name.
Otherwise, I'm not sure that I'm understanding you correctly. Perhaps what you want to do is JTextField.setEditable(false) to not allow any further changes to the JTextField.
At any rate, Good Luck.
-Dirk Schreckmann
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Per Dirks suggestion
jiwang,
Please change your displayed name to be compliant with JavaRanch's naming policy.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
[ March 01, 2002: Message edited by: Cindy Glass ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic