File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "text event" Watch "text event" New topic
Author

text event

kelly devon
Ranch Hand

Joined: Apr 15, 2004
Posts: 75
hi,
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?


kel
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8710
    
    6

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
satya kalyani
Greenhorn

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();
text2.setDocument(text1.getDocument());
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: text event
 
Similar Threads
text filed and button validation
Focus Gained event
swing concept
Unknown Subclasses
<sx:tabbedpanel with textbox issue