File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Populate the 'current' JTextField via a button/label Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic

Populate the 'current' JTextField via a button/label

Lee Quinlan

Joined: Aug 25, 2009
Posts: 9
This is my first post.! I'm hoping it's clear and concise enough for constructive replies !
I'm working on a very simple app for my PPC, trying to make best use of screen real estate and simplify text entry.
The application has a simple form with numerous text fields and I'd like to be able to click a button/label titled 'N/A' to populate the textfield that currently has focus with the same value ('N/A').
In other words, I want to click in the text field I want to popluate with N/A and instead of using the SIP keyboard and typing 'N/A' every time, I want to use a single '"N/A' button/label for any field.
I'm trying to write efficient code and so trying to avoid multiple buttons that just populate their neighboring textfield.
I've done plenty of goolge'ing before making this post but couldn't find anything that fit my scenario.
I get the feeling I should be capturing focus events, determining the component name that triggered the event and then '.setText'ing that component.
Easier said than done for me at my level though
Any help greatly appreciated.
Lee Quinlan

Joined: Aug 25, 2009
Posts: 9
Apologies. I figured this post was best placed in the Beginning Java forum.
Posted in 'Beginning Java' instead
Rob Spoor

Joined: Oct 27, 2005
Posts: 20276

Let's close this one and move the other thread here.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Populate the 'current' JTextField via a button/label
jQuery in Action, 3rd edition