Maybe try adding a mouseListener
combo.addMouseListener(
new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
if (!event.isPopupTrigger())
{
// do whatever it is you're trying to do
}
}
);
Michael Mueller - 08 Mar 2006 05:46 GMT
falcone88@gmail.com schrieb:
> Maybe try adding a mouseListener
>
[quoted text clipped - 9 lines]
> }
> );
MouseListner is still implemented - but I don't receive MouseEvents :(
> Why don't I get any mouse event?
You are adding a MouseListener to a combo box. Typically a JComboBox is
made up of multiple components. The mouse events fire on the
subcomponents, not the JComboBox itself. (Mouse events are a bit odd, in
that they do actually bubble up, but only from components without mouse
listeners attached.)
> While clicking onto the arrow to open the box, I want to load/change the
> contend of the box. Doing this in popupMenuBevomeVisible - one of the
> few events I get - is too late. Is there any event to receive to
> populate the box after clicking the button?
What if the combo is opened using F4, Alt-Down or some other way? A
better approach is to use a lazily loading model.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
Michael Mueller - 09 Mar 2006 06:43 GMT
Thomas Hawtin schrieb:
> You are adding a MouseListener to a combo box. Typically a JComboBox is
> made up of multiple components. The mouse events fire on the
> subcomponents, not the JComboBox itself. (Mouse events are a bit odd, in
> that they do actually bubble up, but only from components without mouse
> listeners attached.)
I inserted this code.
for (int i=0; i<combo.getComponentCount(); i++) {
combo.getComponent(i).addMouseListener(this);
combo.getComponent(i).addMouseMotionListener(this);
}
Now I get my mouse events - great hint. Thanks
> What if the combo is opened using F4, Alt-Down or some other way? A
> better approach is to use a lazily loading model.
Of course, a mouse event is not usefull in this case. Even it appears
after the MenuBecomesVisible, which is much too late.
Anybody has some hint to put me on the way with lazily loading model?
BTW: I never used a spezial combo model. Can I use it to create boxes
with multiple columns?
Michael