aspose file tools
The moose likes Java in General and the fly likes Able to Copy  Text from Text Boxes(JTextfields) in Linux/Solaris Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Able to Copy  Text from Text Boxes(JTextfields) in Linux/Solaris" Watch "Able to Copy  Text from Text Boxes(JTextfields) in Linux/Solaris" New topic
Author

Able to Copy Text from Text Boxes(JTextfields) in Linux/Solaris

macharla happy
Greenhorn

Joined: Sep 01, 2010
Posts: 4
Hi please any one can help me on this,

I have JTextfields in my application, i have overrided the JTextfield copy method using

public void copy();
Jtextfield.setHighlighter(null);

So i am not able to copy text from JTextfield to other text editor in windows.

In Linux/Solaris MouseDrag on Jtextfield data and paste in text editor also not able to paste data
but MouseDrag on Jtextfield data and using center button of mouse(scroller) able to paste data on other text editor
same thing is happening with double click and tab also.

In windows it's working fine.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Why would you deliberately want to break copy/paste functionality?
macharla happy
Greenhorn

Joined: Sep 01, 2010
Posts: 4
David Newton wrote:Why would you deliberately want to break copy/paste functionality?


I am using JTextfield for entering security related informaition
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If they're entering it, couldn't they just enter it somewhere else anyway?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
a JPasswordField might be an option
macharla happy
Greenhorn

Joined: Sep 01, 2010
Posts: 4
Michael Dunn wrote:a JPasswordField might be an option


I am using JTextfield for entering ID not password
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And why would you care if they copied a username out of that field?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

So you'll prevent them to copy it. But they can still read it. So they simply type it into a text editor, and can copy it from there.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
macharla happy
Greenhorn

Joined: Sep 01, 2010
Posts: 4
Rob Prime wrote:So you'll prevent them to copy it. But they can still read it. So they simply type it into a text editor, and can copy it from there.


Hi,

Thanks to all for your reply, I have found solution for this

private void pasteToClipBoard() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Clipboard clipboard = toolkit.getSystemClipboard();
StringSelection selection = new StringSelection(myTextField.getText());
clipboard.setContents(selection, null);
}
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

I thought you wanted to prevent copying data from the text field. This does the exact opposite.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Able to Copy Text from Text Boxes(JTextfields) in Linux/Solaris
 
Similar Threads
Copying into JTextField from Excel
Copying JTable's data to clipboard in Unix/Linux
Which one, VB.Net or java ???
Serial Port Ethernet
Drag and Drop