Share on Google+Share on Google+

1 Answer(s)      9 years ago
Posted in : Swing AWT
View Answers

August 25, 2008 at 1:11 PM

H friend,

import java.awt.*;
import java.util.*;
import java.awt.BorderLayout;
import java.awt.Container;
import java.util.Hashtable;
import java.awt.TextArea;
import java.awt.TextComponent;
import javax.swing.*;
import javax.swing.JScrollPane;
import javax.swing.text.DefaultEditorKit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.AbstractButton;

public class CutPastAWT {
public static void main(String args[]) {
JFrame frame = new JFrame("simple Cut and paste Example");

Container content = frame.getContentPane();
JTextField textField = new JTextField("", 30);
JTextArea textArea = new JTextArea(" ",4, 25);
JScrollPane scrollPane = new JScrollPane(textArea);

content.add(textField, BorderLayout.NORTH);
content.add(scrollPane, BorderLayout.CENTER);

Action actions[] = textField.getActions();

Action cutAction = TextAction.findAction(actions, DefaultEditorKit.cutAction);
Action copyAction = TextAction.findAction(actions, DefaultEditorKit.copyAction);
Action pasteAction = TextAction.findAction(actions, DefaultEditorKit.pasteAction);

JPanel panel = new JPanel();
content.add(panel, BorderLayout.SOUTH);

JButton cutButton = new JButton(cutAction);


JButton copyButton = new JButton(copyAction);


JButton pasteButton = new JButton(pasteAction);

frame.setSize(400, 400);

class TextAction {
private TextAction(){

public static Action findAction(Action actions[], String key) {
Hashtable commands = new Hashtable();
for (int i = 0; i < actions.length; i++) {
Action action = actions[i];
commands.put(action.getValue(Action.NAME), action);
return (Action) commands.get(key);




Related Tutorials/Questions & Answers:
JSP & Swings
JSP & Swings  How to integrate jsp and swings
swings question
swings question  how to change the background color with the help of color values by using swings
swings for webnms
swings for webnms  if i am expanding node of jtree then i want to collapse previous expanding node of jtree in swings how is it possible
Swings JTable
Swings JTable  add values to JTable with four coloums,two of them are comboboxes
Swings & JSP
Swings & JSP  Hai all, Can we use Swing components in a JSP?? Suppose if we enter details in a swing dialog box..and If we want the result in a JSP..is that possible??? Thank you
Java Swings
Java Swings  I am doing one project on java Swings, in this i have created one jframe where i defined some JButtons and Jcombobox's, here i need to insert one JTable with headers(IN CURRENT JFrame only).pls help me urgently
swings header
swings header   have a string1 it contains 3 parts,for example "123456 service hello" and string2 contains text "change request " like this. and the string3 should contain "123456 +(second string)+ hello" "second string can
","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; for(i = 0
Swings and JDBC
Swings and JDBC  Hi.. I am vinay.. I am developing a small application using swings and mysql. I am sending part of the code here.. The problem is i need to update the mysql fields with values which are gettin from dynamiclly
Swings - Applet
Swings  Sir, I have developed an application in swings i want to call that class in applet. is it possible. or otherwise is there any way to deploy java class in browser. Give an example... Thanks in advance...  Hi
java swings - Java Beginners
java swings   Do you want to add textfields on the JPanel
Image Movement using Swings
Image Movement using Swings  How to move image using Swings
how to create frame in swings
how to create frame in swings  how to create frame in swings
Swings/awt - Swing AWT
Swings/awt  Hi, how to write action listeners to the Buttons in RichTextEditor tool bar.. thanks in advance...it's Urgent... i am very much new to Swings
java swings - Java Beginners
java swings   Hi, I need the code for click the refresh button then list values will be refresh.Please send the code ........... Thanks, Valarmathi
java code using swings
java code using swings  code that should be able to enter data of student details using all swings into the access database using jdbc connectivity
An application using swings and vector methods
An application using swings and vector methods   Hi, I want an application in Java swings which uses good selection of Vectors methods
about swings - Java Beginners
about swings   Dear sir,Good evening, i am doing mca sir,i am doing the project in swings,so plz provide the material about swings sir Thank you  Hi Friend, Please visit the following link
java swings - Java Beginners
java swings   Hi, I need the code for joptionpane with jcombobox. my requirement is click on add button,one joptionpane will come.from the option pane i need to select the combobox values. Please send the sample code
java swings - Swing AWT
java swings  I am doing a project for my company. I need a to show the performance of the employees by using bar bharts. Please give me how can we write the code for bar charts using java swings.  Hi friend, I am
swings window header
swings window header  i have a string1 it contains 3 parts,for example "123456 service hello" and string2 contains "change request " like this. and the string3 should contain "123456 "........." hello" ".........." can
making of dynamic textfields using swings
making of dynamic textfields using swings  How to make dynamic textfields using java swings
another frame by using awt or swings
another frame by using awt or swings  how to connect one frame to another frame by using awt or swings
how can we store the encrypted passwaord in swings?
how can we store the encrypted passwaord in swings?   how can we store the encrypted passwaord in swings


Advertisement null