has anyone tried to use the DateChooserPanel class in a popup menu? I want to use an inputfield with a button that opens the DateChooserPanel to help the user choosing the date.
It's easy to put it in a JPopupMenu, but it's not so easy to implement that the popup does not close when selecting the month combo box

Any hints?
Uli
Here is the easy test code to play with:
Code: Select all
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JPopupMenu;
import org.jfree.ui.DateChooserPanel;
public class DateChooserPanelTest
extends JFrame
{
public DateChooserPanelTest()
{
super();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(new JFormattedTextField(new Date()), BorderLayout.CENTER);
JButton popup = new JButton("v");
popup.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
DateChooserPanel dcp = new DateChooserPanel();
JPopupMenu mn = new JPopupMenu();
mn.setLayout(new BorderLayout());
mn.add(dcp, BorderLayout.CENTER);
JComponent j =(JComponent)e.getSource();
mn.show(j,0,j.getHeight());
}
});
getContentPane().add(popup, BorderLayout.EAST);
pack();
}
/**
* @param args
*/
public static void main(String[] args)
{
DateChooserPanelTest dt = new DateChooserPanelTest();
dt.setVisible(true);
}
}