java - Why isn't componentHidden called for my JPopupMenu? -


Text after "

I want to send notifications when my JPopupMenu is hidden - regardless of the selection of an item The menu was dismissed, or the setvibal (false) was called upon to it. Here is my test code:

  import javax.swing *; Import java.awt. *; Import java.awt.event. *; Public Class A extended Kmponentadaptr Rnnbl, Akshnlistr (private Jebtn B; public static void main (String [] Arges) {EventQueue.invokeLater (new A ());} public void run () {JFrame f = new JFrame ( "test" ); b = new Jebtn ( "Click me"); b.addActionListener (this); f.add (b); Fkpack (); FksetVisible (right);} public void Kriyaprwartit (Akshnavent e) { JPopupMenu pm = new JPopupMenu (); pm.addComponentListener (this); pm.add ( "pop ..."); pm.add ( "... the menu!"); Pm.show (B, 10, 10) ;} Visible public null component IES (Component Avant e) {System.out.println ( "component shows");} public void Gtkhinder (component Avant e) {System.out.println ( "Gtkhad");}}  

How do I interact with the menu, two ComponentListener methods are not being called too. Why is it?

Thanks

Cameron

  pm.addPopupMenuListener ( New PopupMenuister () {@ Override Public Wide Popup menu was aborted (PopupMenuivEE) {S ystem.out.println ( "Cancel");} @Override public void popupMenuWillBecomeInvisible (PopupMenuEvent e) {println ( "vanishing");} @Override public void popupMenuWillBecomeVisible (PopupMenuEvent e) {println ( "a" is displayed) ;}});  

Edit: Whoops, it seems as if someone chose to reply in the comment. My bad

Edit2 :. is not sending events on the menu disappear, might explain it:

When component-hidden and component-shown events As a result of calls to the setVisible method of only one component. For example, without a window, a component-hidden icon may be small in the event the event is being removed

Source: (non-statutory) Probably, but from the horse's mouth.)

Consider that is setVisible in conjunction with the implementation of JPopupMenu:

  public Zero setVisible (boolean b) {// not supported for MenuComponents}  

And you know how this can happen, but not In why this happens (it has written what is the rationale and where exactly?)


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -