jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes text event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "text event" Watch "text event" New topic

text event

kelly devon
Ranch Hand

Joined: Apr 15, 2004
Posts: 77
i am writing a program whereby i'll have twoo text fields
and once i enter a text in one text field, i want it to display in the other textfield without me clicking on any buttons, the only button there will be
the exit button.in the textvaluechanged method of the textfield, how do i get it to return true if there is something written in the textfield?
help pls this textListener is kinda new to me. how do use the actionlis
tener with getting a value in the JTexxfield or know when something has been typed in the field?

Joe Ess

Joined: Oct 29, 2001
Posts: 9169

If you want the text to appear in both fields as it is being typed, you will want a Key Listener. Text Listener informs you that a field has been changed once the change is complete. Take a look at the Java Tutorial chapter on How to Write a Key Listener for examples.

[How To Ask Questions On JavaRanch]
satya kalyani

Joined: Jan 07, 2005
Posts: 2
get document of first textfield and set it as the document to the second textfield, something similar to the code below

JTextField text1 = new JTextField("Test");
JTextField text2 = new JTextField();
I agree. Here's the link: http://aspose.com/file-tools
subject: text event
It's not a secret anymore!