How to disable the popup of JComboBox?

I just used the JCelendar which use a JComboBox to display a date chooser. It is interesting that it disable the default list popup and use a date chooser dialog instead.

I have tried a lot (such as implementing the PopupMenuListener, setPopupVisible(false) and etc) but can not find the way to perfectly achieve that. And it seems that JCenlendar source code is not free. Can anyone help? Thanks.

[410 byte] By [tmdfana] at [2007-11-26 17:02:03]
# 1
dig into BasicComboBoxUI's createPopup() and give it a preferredSize of (0,0)
Michael_Dunna at 2007-7-8 23:29:48 > top of Java-index,Desktop,Core GUI APIs...
# 2

if you can deal with the flicker:

import java.awt.*;

import javax.swing.*;

import javax.swing.event.PopupMenuEvent;

import javax.swing.event.PopupMenuListener;

public class DisablePopupTest {

public static void main(String[] args) {

final JComboBox c = new JComboBox();

c.addPopupMenuListener(new PopupMenuListener() {

public void popupMenuCanceled(PopupMenuEvent e) {}

public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}

public void popupMenuWillBecomeVisible(PopupMenuEvent e) {

System.out.println(e.getSource());

SwingUtilities.invokeLater(new Runnable() {

public void run() {

JPopupMenu m = new JPopupMenu("Menu");

m.add(new JMenuItem("TEST"));

m.setPreferredSize(new Dimension(200, 100));

m.show(c, 0, c.getHeight());

c.setPopupVisible(false);

}

});

}

});

JFrame f = new JFrame("Test");

f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

f.getContentPane().setLayout(new FlowLayout());

f.getContentPane().add(c);

f.setSize(600, 400);

f.setVisible(true);

}

}

Jasprea at 2007-7-8 23:29:48 > top of Java-index,Desktop,Core GUI APIs...
# 3
I have tried all the ways listed in the following thread http://forum.java.sun.com/thread.jspa?forumID=57&threadID=781849It seems that only set the size to be zero will leads to some other problem.
tmdfana at 2007-7-8 23:29:48 > top of Java-index,Desktop,Core GUI APIs...
# 4
> It seems that only set the size to be zero will leads to some other problem.for a solution to your 'other problem' http://www.mindreaders.com/
Michael_Dunna at 2007-7-8 23:29:48 > top of Java-index,Desktop,Core GUI APIs...