473,395 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

JTextField and JTextArea

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
2 2342
Nepomuk
3,112 Expert 2GB
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
JosAH
11,448 Expert 8TB
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

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

Similar topics

1
by: - ions | last post by:
Hello, i am relatively new to programming, Java being the first language im learning. At the moment im having trouble changing the setEnable value of a button, relative to the state of a JTextArea,...
1
by: Chris Williams | last post by:
I haven't done any Java programming for a good long bit, so this is probably something really silly but anyways, can anyone tell me why my JTextArea is not appearing when I run this? public...
1
by: Colibasi | last post by:
I would like to have a JTextArea with a background white and text should be readonly. The way I tried is something like this: JTextArea text = new JTextArea(); text.setEditable(false);...
0
JoeMac3313
by: JoeMac3313 | last post by:
The question is how can I update the JTextField in Class CreditDisplayField when I hit the button in class CreditButton? I wrote in a test printing to console to make sure the "logic.addCredits();"...
2
by: all eyes | last post by:
hi all, i am using here JTextField to get sum of all previously pressed numbers in one button called (+) and so on. there is only one button take care of addition and displaying the result in the...
1
by: ahmed222too | last post by:
the jtextfield donot accept Arabic language font when i run this code jtextfield.settext="ذهب الولد إلى المدرسة"; the arabic font change into another font in the jtextfield
4
by: ahmed222too | last post by:
when i read data from file by code into jtextfield the lines of the file apprear in Concatenation in the jtextfield (without Enters between lines) i want to transfere the content of the file to the...
1
by: dig909 | last post by:
I am trying to compare a number inserted into a jtextfield with a number generated with the program. Unfortunately the numbers never evaluate as equal. Here is an example of the code I'm working...
1
by: chanshaw | last post by:
Ok my problem is that when it loads the JTextArea, it does not show the full component's width and height. I've tried specifying it with setrow, setcolumn, setprefferedsize, all of that. It does...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.