Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / April 2006

Tip: Looking for answers? Try searching our database.

JTextArea and Image sharing same GUI space

Thread view: 
cci_bz-java@yahoo.com - 22 Apr 2006 07:56 GMT
To display a message in a GUI, I am using a JTextArea defined as:
    JTextArea message = new JTextArea(1,1);

To put the desired real data in the JTextArea (and thus display on the
GUI) I use a statement like this:
    message.replaceRange(data.freeText, 0,
message.getText().length());

This works fine for the normal situation. But on occasion, the area of
the GUI where this message appears needs to instead display an image;
in which case, I want the contents of this message to be empty.
Otherwise the message displays on top of (or nibbling into) my image.

In an effort to keep the message from displaying, I've tried this:
    message.replaceRange("", 0, message.getText().length());
And this:
    message.replaceRange("", 0, 1);
And this:
    message.setText("");

All of these result in a "blank" message (i.e., there is no text
displayed), but an equivalent empty/blank "footprint" (of the
message) still appears and corrupts the image I'm displaying.

Is there a way to "clear" the contents of my JTextArea so that it
doesn't display anything at all (i.e., no message and no blank
footprint)?

I know I could just refrain from painting the JTextArea at all
(whenever the image is to display), but in my case that's a separate
piece of logic that I'd just soon not mess with.

Any ideas?
hiwa - 22 Apr 2006 10:51 GMT
We may need to see your code, especially its layout related part.
Post a small demo code that is generally compilable, runnable and
could reproduce your problem. See:
http://homepage1.nifty.com/algafield/sscce.html

How about remove(message) or pack() on the container?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.