Hi all,
i prepered a menu that have a small editor to add text,i'm cannot find
the method of copy ,paste and cut
any idea?
John B. Matthews - 29 Jun 2009 20:39 GMT
In article
<113787bb-1c43-431a-a30e-ed66766879e1@x5g2000yqk.googlegroups.com>,
[...]
> I prepered a menu that have a small editor to add text; I cannot find
> the method of copy, paste and cut
[...]
You might look at the class Clipboard:
<http://java.sun.com/javase/6/docs/api/java/awt/datatransfer/Clipboard.html>
<http://mindprod.com/jgloss/clipboard.html>

Signature
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
Roedy Green - 29 Jun 2009 22:06 GMT
>i prepered a menu that have a small editor to add text,i'm cannot find
>the method of copy ,paste and cut
See java.awt.DataTransfer
To see how to use it, have a look at the source code for
http://mindprod.com/applet/isbn.html

Signature
Roedy Green Canadian Mind Products
http://mindprod.com
"Deer hunting would be fine sport, if only the deer had guns."
~ William S. Gilbert of Gilbert and Sullivan
Knute Johnson - 29 Jun 2009 22:30 GMT
> Hi all,
> i prepered a menu that have a small editor to add text,i'm cannot find
> the method of copy ,paste and cut
>
> any idea?
Basic cut, copy and paste just work on JTextComponents. What exactly do
you want to do?

Signature
Knute Johnson
email s/nospam/knute2009/
markspace - 29 Jun 2009 22:57 GMT
> Hi all,
> i prepered a menu that have a small editor to add text,i'm cannot find
> the method of copy ,paste and cut
>
> any idea?
TextArea, or JTextArea? They are different, you should probably be
using the latter.
javax.swing.text has some default actions for the Edit menu. Most of
Swing's components work correctly already, no need to do anything to
them. To set up the Edit menu, use something like this:
public static void setUpXCVEditMenu( javax.swing.JMenu menu )
{
javax.swing.JMenuItem menuItem;
menuItem = new javax.swing.JMenuItem(
new javax.swing.text.DefaultEditorKit.CutAction());
menuItem.setText("Cut");
menuItem.setMnemonic(java.awt.event.KeyEvent.VK_T);
menu.add(menuItem);
menuItem = new javax.swing.JMenuItem(
new javax.swing.text.DefaultEditorKit.CopyAction());
menuItem.setText("Copy");
menuItem.setMnemonic(java.awt.event.KeyEvent.VK_C);
menu.add(menuItem);
menuItem = new javax.swing.JMenuItem(
new javax.swing.text.DefaultEditorKit.PasteAction());
menuItem.setText("Paste");
menuItem.setMnemonic(java.awt.event.KeyEvent.VK_P);
menu.add(menuItem);
}
thread - 30 Jun 2009 10:05 GMT
> > Hi all,
> > i prepered a menu that have a small editor to add text,i'm cannot find
[quoted text clipped - 30 lines]
>
> }
hi,
i'm using the TextArea
John B. Matthews - 30 Jun 2009 15:45 GMT
In article
<8aa3a957-bac6-45eb-82f6-ba2b36b7727e@y9g2000yqg.googlegroups.com>,
> On 29 יוני, 23:57, markspace <nos...@nowhere.com> wrote:
> > > Hi all,
> > > i prepered a menu that have a small editor to add text,i'm cannot find
> > > the method of copy ,paste and cut
>
> > > any idea?
>
> > TextArea, or JTextArea? They are different, you should probably be
> > using the latter.
>
> > javax.swing.text has some default actions for the Edit menu. Most
> > of Swing's components work correctly already, no need to do
> > anything to them. To set up the Edit menu, use something like
> > this:
[...]
> i'm using the TextArea
You might like to look at JTextArea, which is "a lightweight component
that provides source compatibility with the java.awt.TextArea class." It
supports the editing activities you require with straightforward code,
such as Mark Space suggested:
<http://java.sun.com/javase/6/docs/api/javax/swing/JTextArea.html>
<http://java.sun.com/docs/books/tutorial/uiswing/components/text.html>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>