I have written following code.
package com.applet;
import java.applet.Applet;
import java.util.Hashtable;
import javax.swing.Action;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.text.DefaultEditorKit;
public class ClipBoard extends Applet {
JTextField textField = null;
Action actions[] = null;
JButton cutButton = null;
JButton copyButton = null;
JButton pasteButton = null;
public void init() {
textField = new JTextField(20);
add(textField);
actions = textField.getActions();
Action cutAction = findAction(actions, DefaultEditorKit.cutAction);
Action copyAction = findAction(actions, DefaultEditorKit.copyAction);
Action pasteAction = findAction(actions, DefaultEditorKit.pasteAction);
cutButton = new JButton(cutAction);
cutButton.setText("Cut");
add(cutButton);
copyButton = new JButton(copyAction);
copyButton.setText("Copy");
add(copyButton);
pasteButton = new JButton(pasteAction);
pasteButton.setText("Paste");
add(pasteButton);
}
public static Action findAction(Action actions[],
String key) {
Hashtable<Object, Action> commands = new Hashtable<Object, Action>();
for (int i = 0; i < actions.length; i++) {
Action action = actions[i];
commands.put(action.getValue(Action.NAME), action);
}
return commands.get(key);
}
}
-----------------------------------ClipBoard.html-------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head><body>
<APPLET CODE="com.applet.ClipBoard.class" WIDTH=460 HEIGHT=160></APPLET>
</body>
</html>