JTable that copy data from Excel

HI.

I use class which can copy and paste from Excel

http://www.javaworld.com/javaworld/javatips/jw-javatip77_p.html

but i got problem.....

I want to make a popup menu which can use keybord shortcuts CTRL+C to copy and CTRL+V to paste.

How will be look like my popup menu ? I have now idea how to call and use shortcuts, and those that i have written doesn't work:

Here is my popup menu

// popup menu

// import table somewhere in program

publicvoid createPopupMenu(Jtable table){

JMenuItem menuItem;

JPopupMenu popup =new JPopupMenu();

menuItem =new JMenuItem("Copy CTRL+C");

menuItem.setAction(/* here should i use CTRL+C*/);

menuItem.addActionListener(this);

popup.add(menuItem);

menuItem =new JMenuItem("Paste CTRL+V");

menuItem.setAction(/* here should i use CTRL+V*/);

menuItem.addActionListener(this);

popup.add(menuItem);

// listen to the table

MouseListener popupListener =new PopupListener(popup);

table.addMouseListener(popupLitstener)

}

[1620 byte] By [Lukasz_1981a] at [2007-11-26 19:41:43]
# 1

Isn't it popup menu meant to work on right clicks?

I'm not sure whether popup menus can have accelerators, or the accelerators will work when the popup menu is not visible. You can have accelerators on JMenuBar, which is attached on JFrame normally.

Or you can make the program respond to key press directly without the menus: [url=http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]How to use Key Bindings[/url]

Message was edited by:

Icycool

Icycoola at 2007-7-9 22:23:11 > top of Java-index,Desktop,Core GUI APIs...