posted 18 years ago
Hi All,
I've build a custom Date picker utility that looks like a JComboBox, but is actually a JTextField next to a JButton, which when clicked displays a JPopupMenu. It's a long story, but extending JComboBox caused far more problems than it solved.
My problem is that I need the popup to hide whenever blank areas (unused portions) of the enclosing JPanel are clicked. It seems JPanel does not fire a focusGained event when it is clicked in this way. JComboBox instances hide their menus in this scenario, but I've not found the code in its class definition that makes this magic happen.
Here are the particulars of my code:
My JPopupMenu has a custom UI, which I extended from BasicPopupMenuUI:
Here is the code I use to display the popup:
I then have a FocusListener which closes the popup when it, or the adjoining JTextField lose focus:
I'd love to hear any advice/tips any of you might have.
Thanks very much,
Diana