Results 1 to 4 of 4
Thread: JPopupMenu problem
- 10-03-2008, 03:26 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 3
- Rep Power
- 0
JPopupMenu problem
I have a problem with my JPopupMenu. I have no problem opening it. There is even no problem using it. The menu-items react on the action. But when a menu-item is clicked, normally, the background automatically changes color. In my case, that doesn't happen. Can anyone help?
This is my popupmenu.
This is how I tested it.Java Code:public class JOrderPopupMenu extends JPopupMenu implements ActionListener{ private JMenuItem mniMemo; private JMenuItem mniNosRef; public JOrderPopupMenu(){ mniMemo = new JMenuItem("Memo"); mniNosRef = new JMenuItem("No_Stock_Referentie"); mniMemo.addActionListener(this); mniNosRef.addActionListener(this); JCheckBoxMenuItem test = new JCheckBoxMenuItem("test"); add(mniMemo); add(mniNosRef); add(test); } public void actionPerformed(ActionEvent e) { System.out.println("actionPerformed"); if( (JMenuItem)e.getSource() == mniMemo){ System.out.println("mniMemo"); } else if ((JMenuItem) e.getSource() == mniNosRef){ System.out.println("mniNosRef"); } } }
Can anyone help?Java Code:public class TestPopup extends JPanel implements MouseListener{ private JOrderPopupMenu jOrderPopupMenu; public TestPopup(){ JButton btnTest = new JButton("Test"); btnTest.addMouseListener(this); add(btnTest); jOrderPopupMenu = new JOrderPopupMenu(); } public static void main(String[] args) { JFrame frame = new JFrame(); frame.setContentPane(new TestPopup()); frame.pack(); frame.setVisible(true); } public void mouseClicked(MouseEvent arg0) { } public void mouseEntered(MouseEvent arg0) { } public void mouseExited(MouseEvent arg0) { } public void mousePressed(MouseEvent arg0) { } public void mouseReleased(MouseEvent e) { if(e.isPopupTrigger()){ jOrderPopupMenu.setVisible(true); } } }
- 10-04-2008, 12:23 AM #2
Use the show method vs setVisible
- 10-06-2008, 08:35 AM #3
Member
- Join Date
- Oct 2008
- Posts
- 3
- Rep Power
- 0
I didn't use the show method because it is deprecated. Isn't setVisible the alternative?
Greetz
- 10-06-2008, 08:37 AM #4
Member
- Join Date
- Oct 2008
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
JPopupMenu
By hungleon88 in forum NetBeansReplies: 8Last Post: 01-15-2009, 05:00 PM -
JPopupMenu falls behind window
By undertow in forum AWT / SwingReplies: 4Last Post: 01-17-2008, 10:20 PM -
dynamising the height of a JPopupMenu
By iimasd in forum AWT / SwingReplies: 6Last Post: 11-21-2007, 10:01 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks