Skip to main content

JXDatePicker popupButton

5 replies [Last post]
Anonymous

I've realized that when using the JXDatePicker out of the box the size of the popup button is considerably larger than when I view the JXDatePicker in the SwingLabs demo. I've been digging through the source and UI classes but cannot find where the Demo sets the size of the button?

Can someone please give me a hint on how I can easily control the size of the popup button,

Thanks!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dmouse
Offline
Joined: 2003-06-09
Points: 0

The code for laying out the date picker component is in BasicDatePickerUI.layoutContainer(). The height of the button is currently set to be as tall as the editor it is assocaited with. The width is the preferred width depending on the image set on the button.

rasto1968
Offline
Joined: 2004-08-25
Points: 0

I've seen the same problem. I've had a play with BasicDatePickerUI and adding the following code to createPopupButton seems to help:

b.setMargin(new Insets(1,1,1,1));

I'm embedding the date picker in a JTable, so ideally I would like to get rid of the popup button altogether and have the picker dialogue be displayed when the user clicks on the date - is this possible ?

Rob

dmouse
Offline
Joined: 2003-06-09
Points: 0

The UI for the DatePicker does already support layout without the popup button. You may need to subclass the UI and install it but otherwise I believe it will work.

There is also a RFE for a cell editor implementation of the data picker which will hopefully solve this issue in the long run.

rasto1968
Offline
Joined: 2004-08-25
Points: 0

> The UI for the DatePicker does already support layout
> without the popup button. You may need to subclass
> the UI and install it but otherwise I believe it will
> work.
>
> There is also a RFE for a cell editor implementation
> of the data picker which will hopefully solve this
> issue in the long run.

Thanks for that. Having played around a bit with it I now find that I quite like having the button in the cell editor anyway :)

What did you think about my patch for setting the insets on the button so that it doesn't take up so much space ?

Rob

dmouse
Offline
Joined: 2003-06-09
Points: 0

I looked at the patch a few days ago. I'll run it by the HI folks and see what they say. Either way thank you very much for the patch. It is very much appreciated.