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.