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 / February 2004

Tip: Looking for answers? Try searching our database.

Selectable/Copyable JLabel Text

Thread view: 
Reinhard Engels - 06 Feb 2004 20:02 GMT
I display information in a JLabel that I would like users to be able
to copy. They can't. From what I understand, that's just the way
JLabels work. Is there any other component that will make text look
just like a JLabel but be selectable/copyable? I know I can use a
non-editable JTextField/TextArea/TextPane but I don't want to use
something that looks like a form input field. I must be using the
wrong terms, because this seems like second grade java and
google/doorstops are giving me nothing.

Why do I want to do this? So users can copy the version info from my
"about" box into support emails.

Thanks in advance,

Reinhard

http://www.everydaysystems.com
ak - 06 Feb 2004 21:45 GMT
> I display information in a JLabel that I would like users to be able
> to copy. They can't. From what I understand, that's just the way
> JLabels work. Is there any other component that will make text look
> just like a JLabel but be selectable/copyable? I know I can use a
> non-editable JTextField/TextArea/TextPane but I don't want to use
> something that looks like a form input field

try to set border of non-editable JTextField to null or EmptyBorder

> Why do I want to do this? So users can copy the version info from my
> "about" box into support emails.

another possibility is to add dnd handler to your JLabel
____________

http://reader.imagero.com the best java image reader.
Lee Weiner - 06 Feb 2004 23:02 GMT
>I display information in a JLabel that I would like users to be able
>to copy. They can't. From what I understand, that's just the way
[quoted text clipped - 7 lines]
>Why do I want to do this? So users can copy the version info from my
>"about" box into support emails.

   JTextField field = new JTextField( "Dummy Information");
   field.setBorder( null );
   field.setOpaque( false );
   field.setEditable( false );

Looks like a JLabel to me.

Lee Weiner
lee AT leeweiner DOT org
Reinhard Engels - 07 Feb 2004 15:57 GMT
Thanks, Lee. That's perfect. Second grade java alright.

> >I display information in a JLabel that I would like users to be able
> >to copy. They can't. From what I understand, that's just the way
[quoted text clipped - 17 lines]
> Lee Weiner
> lee AT leeweiner DOT org
Nick H - 07 Feb 2004 22:05 GMT
> I display information in a JLabel that I would like users to be able
> to copy.

You could also use a JLabel and provide a "Copy to Clipboard" button,
which will label.getText() and then I'm sure there's clipboard
functionality in Java...

...yup... Class java.awt.datatransfer.Clipboard.


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



©2009 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.