J
javadev
I have a strange problem involving multiple JPopupMenus.
I have a JPanel from which I open a JPopupMenu. From this menu I open
another JPopupMenu. The problem is for any mouseClicked event anywhere
on the 2nd popup menu, the menu loses focus and disappears behind the
parent JFrame.
Is this something common and is there a workaround to it? Or is there
something wrong I am doing?
Following is the code:
// firstMenu is the JPopupMenu created from the JPanel
openButton = new JButton("Open Popup");
openButton.setActionCommand("open");
openButton.addActionListener(new ButtonClickListener());
firstMenu.add(openButton);
Here is the code for the ButtonClickListener:
class ButtonClickListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("open"))
{
JPopupMenu secondMenu = new JPopupMenu();
// add components to the menu
secondMenu.show();
}
}
}
Any help would be greatly appreciated.
Thanks
SS
I have a JPanel from which I open a JPopupMenu. From this menu I open
another JPopupMenu. The problem is for any mouseClicked event anywhere
on the 2nd popup menu, the menu loses focus and disappears behind the
parent JFrame.
Is this something common and is there a workaround to it? Or is there
something wrong I am doing?
Following is the code:
// firstMenu is the JPopupMenu created from the JPanel
openButton = new JButton("Open Popup");
openButton.setActionCommand("open");
openButton.addActionListener(new ButtonClickListener());
firstMenu.add(openButton);
Here is the code for the ButtonClickListener:
class ButtonClickListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("open"))
{
JPopupMenu secondMenu = new JPopupMenu();
// add components to the menu
secondMenu.show();
}
}
}
Any help would be greatly appreciated.
Thanks
SS