Using an ItemListener on JMenu
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Cory_Twibell
Posted On:   Wednesday, December 5, 2001 11:08 AM

I am using an ItemListener on a JMenu to validate fields before showing the menu. I'm using menu.addItemListener( new ItemListener() { public void itemStateChanged( ItemEvent e ) { JMenu m = (JMenu) e.getItem(); if ( e.getStateChanged() == ItemEvent.SELECTED ) { if ( !validateFields() ) // which shows a JOptionPane error { m.getPopupMenu().setVisible( false ); } } } } ); The popup menu is still visible. I checked the popup elements and it contains my text, so I know I am receiving the correct object. How can I hide the popup menu?    More>>

I am using an ItemListener on a JMenu to validate fields
before showing the menu. I'm using


			menu.addItemListener( new ItemListener()
			
{
public void itemStateChanged( ItemEvent e )
{
JMenu m = (JMenu) e.getItem();
if ( e.getStateChanged() == ItemEvent.SELECTED )
{
if ( !validateFields() ) // which shows a JOptionPane error
{
m.getPopupMenu().setVisible( false );
}
}
}
} );


The popup menu is still visible. I checked the popup elements
and it contains my text, so I know I am receiving the correct object.
How can I hide the popup menu?

   <<Less
About | Sitemap | Contact