Java World
May 9th, 2000, 03:24 PM
I created a class with two text field and two buttons, Copy and Paste. Type some text in the one of the text field and hit Copy I put the text in the clip board by using
Clipboard system = Toolkit.getDefaultToolkit().getSystemClipboard();
String strData = textField1.getText();
stsel = new StringSelection(strData);
system.setContents(stsel,stsel);
Hit Paste button and I reads the data from the Clip board and puts it in another text field. Here is the following code:
try
{
String trstring = (String)(system.getContents(null).getTransferData(DataFlavor.stringFlavor));
TextField2.setText(trstring);
}
This works fine if I attach this class from Application and does not work if the same class is attached to a Applet. WHY !!!! am I doing something wrong !!!??
Can anyone help me, with this stupid thing.
Clipboard system = Toolkit.getDefaultToolkit().getSystemClipboard();
String strData = textField1.getText();
stsel = new StringSelection(strData);
system.setContents(stsel,stsel);
Hit Paste button and I reads the data from the Clip board and puts it in another text field. Here is the following code:
try
{
String trstring = (String)(system.getContents(null).getTransferData(DataFlavor.stringFlavor));
TextField2.setText(trstring);
}
This works fine if I attach this class from Application and does not work if the same class is attached to a Applet. WHY !!!! am I doing something wrong !!!??
Can anyone help me, with this stupid thing.