By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,760 Members | 955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,760 IT Pros & Developers. It's quick & easy.

JTextField and JTextArea

P: 8
i have a jtextfield and jtextarea. The textfield displays a file name. Please provide me the code to drag the filename into the textarea , so that the text area displays the fie contents....
Aug 31 '07 #1
Share this Question
Share on Google+
2 Replies


Nepomuk
Expert 2.5K+
P: 3,112
i have a jtextfield and jtextarea. The textfield displays a file name. Please provide me the code to drag the filename into the textarea , so that the text area displays the fie contents....
That won't be only a little code! First of all, you have to somehow write code, that reacts to you wanting to drag the name from the JTextField (maybe a MouseListener?), then you'll have to make sure it will be draged, next thing you will have to tell the JTextArea what to do, when it gets a Filename draged onto it.

It would be much easier to just have a "Load" Button, which starts a function to read out the Filename from the JTextField, find the File and open the contents in the JTextArea.

By the way, why would you want to have a Filename in a TextField and then want to drag it?

Greetings,
Nepomuk
Aug 31 '07 #2

Expert 10K+
P: 11,448
As Nepomuk suggested: just have a 'load' button. I'd take it a step further and
get rid of the JTextField altogether and have that "load" button popup a
JFileChooser; users are used to those things and you have to write less code
if you do it this way ("less is better" when it comes to program code).

kind regards,

Jos
Aug 31 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.