Example of java. Added this code to a text box
a context menu with the right button with the basic command to copy, cut and paste
.
import javax.swing .*; / / Right button
PopUpMenu PopMenu = new JPopupMenu JPopupMenu ();
PopCortar = new JMenuItem JMenuItem ("Cut");
PopCopiar = new JMenuItem JMenuItem (copy);
PopPegar = new JMenuItem JMenuItem ("Paste");
PopSelTodo = new JMenuItem JMenuItem ("Select All");
JTexttArea JTextArea text = new ();
public Menu () {
/ / JPopupMenu
PopMenu.add (PopCortar)
PopMenu.add (PopCopiar)
PopMenu.add (PopPegar)
add (text);
/ / set the JFrame
PopUpMenu Texto.setComponentPopupMenu (PopMenu)
setTitle ("Sample JPopupMenu");
setSize (800.600);
setVisible (true);
} public static void main (String [] args) {
new Menu ();
}}
0 comments:
Post a Comment