M
Michael Mueller
Greetings!
Please take a look onto following code.
Questions:
Why don't I get any mouse event?
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?
Thanks
Michael
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
@SuppressWarnings("serial")
public class TestForm extends JFrame
implements PopupMenuListener, ActionListener, MouseListener,
AncestorListener, MouseMotionListener {
public TestForm (){
super("Test");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComboBox combo = new JComboBox();
combo.setEditable(true);
combo.addItem("Test1");
combo.addItem("Test2");
combo.addPopupMenuListener(this);
combo.addMouseListener(this);
combo.addActionListener(this);
combo.addAncestorListener(this);
combo.addMouseMotionListener(this);
this.add(combo);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
TestForm frame = new TestForm();
frame.setLocation(700, 500);
frame.pack();
frame.setVisible(true);
new TestForm();
}
public void popupMenuWillBecomeVisible(PopupMenuEvent arg0) {
System.out.println("popupMenuWillBecomeVisible");
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent arg0) {
System.out.println("popupMenuWillBecomeInvisible");
}
public void popupMenuCanceled(PopupMenuEvent arg0) {
System.out.println("popupMenuCanceled");
}
public void actionPerformed(ActionEvent arg0) {
System.out.println("actionPerformed");
}
public void mouseClicked(MouseEvent arg0) {
System.out.println("mouseClicked");
}
public void mousePressed(MouseEvent arg0) {
System.out.println("mousePressed");
}
public void mouseReleased(MouseEvent arg0) {
System.out.println("mouseReleased");
}
public void mouseEntered(MouseEvent arg0) {
System.out.println("mouseEntered");
}
public void mouseExited(MouseEvent arg0) {
System.out.println("mouseExited");
}
public void ancestorAdded(AncestorEvent arg0) {
System.out.println("popupMenuWillBecomeInvisible");
}
public void ancestorRemoved(AncestorEvent arg0) {
System.out.println("popupMenuWillBecomeInvisible");
}
public void ancestorMoved(AncestorEvent arg0) {
System.out.println("ancestorMoved");
}
public void mouseDragged(MouseEvent arg0) {
System.out.println("mouseDragged");
}
public void mouseMoved(MouseEvent arg0) {
System.out.println("mouseMoved");
}
}
Please take a look onto following code.
Questions:
Why don't I get any mouse event?
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?
Thanks
Michael
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
@SuppressWarnings("serial")
public class TestForm extends JFrame
implements PopupMenuListener, ActionListener, MouseListener,
AncestorListener, MouseMotionListener {
public TestForm (){
super("Test");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComboBox combo = new JComboBox();
combo.setEditable(true);
combo.addItem("Test1");
combo.addItem("Test2");
combo.addPopupMenuListener(this);
combo.addMouseListener(this);
combo.addActionListener(this);
combo.addAncestorListener(this);
combo.addMouseMotionListener(this);
this.add(combo);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
TestForm frame = new TestForm();
frame.setLocation(700, 500);
frame.pack();
frame.setVisible(true);
new TestForm();
}
public void popupMenuWillBecomeVisible(PopupMenuEvent arg0) {
System.out.println("popupMenuWillBecomeVisible");
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent arg0) {
System.out.println("popupMenuWillBecomeInvisible");
}
public void popupMenuCanceled(PopupMenuEvent arg0) {
System.out.println("popupMenuCanceled");
}
public void actionPerformed(ActionEvent arg0) {
System.out.println("actionPerformed");
}
public void mouseClicked(MouseEvent arg0) {
System.out.println("mouseClicked");
}
public void mousePressed(MouseEvent arg0) {
System.out.println("mousePressed");
}
public void mouseReleased(MouseEvent arg0) {
System.out.println("mouseReleased");
}
public void mouseEntered(MouseEvent arg0) {
System.out.println("mouseEntered");
}
public void mouseExited(MouseEvent arg0) {
System.out.println("mouseExited");
}
public void ancestorAdded(AncestorEvent arg0) {
System.out.println("popupMenuWillBecomeInvisible");
}
public void ancestorRemoved(AncestorEvent arg0) {
System.out.println("popupMenuWillBecomeInvisible");
}
public void ancestorMoved(AncestorEvent arg0) {
System.out.println("ancestorMoved");
}
public void mouseDragged(MouseEvent arg0) {
System.out.println("mouseDragged");
}
public void mouseMoved(MouseEvent arg0) {
System.out.println("mouseMoved");
}
}