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 / General / November 2006

Tip: Looking for answers? Try searching our database.

JTextArea fun...

Thread view: 
theCassman@googlemail.com - 07 Nov 2006 19:01 GMT
Hi,

I am wanting to have an area of text which will take in sets of
coordinates and display them straight away. Initially, i used a
JTextArea and simply used the .append() method to add the newest
coordinates to the end of the current text. This worked perfectly fine.

However, my problem now is that i want, at some points, one set of
coordinates to display in a different colour to the rest. I.e. The
selected object would have its coordinates highlighted in the text
area. Due to the fact that .setForeground() changes the colour of the
entire contents of the JTextArea; i need to use something else. I have
tried using a JTextPane but cannot work out how to make it append extra
information like the JTextArea does.

Does anybody have any suggestions on what i could use to 1) display
text as i add new objects and 2) have the ability to have different
coloured text. Cheers.

Regards,

Cassman
Oliver Wong - 07 Nov 2006 19:12 GMT
> Hi,
>
[quoted text clipped - 14 lines]
> text as i add new objects and 2) have the ability to have different
> coloured text. Cheers.

   I don't understand what you're trying to do, but if you want different
coloured text, you'll need to use a styled-text component (or write your own
component). See
http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html

   - Oliver
Daniel Pitts - 07 Nov 2006 20:03 GMT
> Hi,
>
[quoted text clipped - 10 lines]
> tried using a JTextPane but cannot work out how to make it append extra
> information like the JTextArea does.

jTextPane.setText(jTextPane.getText() + newText);

> Does anybody have any suggestions on what i could use to 1) display
> text as i add new objects and 2) have the ability to have different
[quoted text clipped - 3 lines]
>
> Cassman

You might also want to use a JList instead, as this seems more like
what you want.
theCassman@googlemail.com - 07 Nov 2006 20:08 GMT
Cheers guys, i will try both of these.

Regards,

Cassman


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.