The Artima Developer Community
Sponsored Link

Java Answers Forum
JPopMenu does not come up

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Barry Dogger

Posts: 7
Nickname: phoenix
Registered: Apr, 2002

JPopMenu does not come up Posted: Apr 5, 2002 5:53 AM
Reply to this message Reply
Advertisement
I have a JTable in MVC model. In the controller I have an inner class called TablePopup. Here is the code:

class TablePopup extends JPopupMenu
{
public TablePopup(JTable table)
{
JMenuItem itemDelete = new JMenuItem("Delete row");
JMenuItem itemAdd = new JMenuItem("Add row");
itemDelete.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.out.println("Delete row");
}
});
itemAdd.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.out.println("Add row");
}
});
add(itemDelete);
add(new JSeparator());
add(itemAdd);
}// End of inner Class TablePopUp

I want to add a popup menu to a Jtable which is initialezed in the view.

In the controller I do:

tablePopup = new TablePopup(table);
table.addMouseListener(new MouseAdapter()
{
public void mouseReleased (MouseEvent e)
{
if (e.isPopupTrigger())
{
System.out.println("Popup Trigger!");
tablePopup.show (e.getComponent(), e.getX(), e.getY());
}
}
});

I get the System.out.println("Popup Trigger!"); but the popup does not come up. When I right click, I see a small white panel but it is only there for a second.

Can someone help me out here?

Thanks in advance.

Grtx,
Barry

Topic: query about paint() method in graphics Previous Topic   Next Topic Topic: java + win2000

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use