Reputation: 16375
I want a datepicker in my jframe. I am using JXDatePicker from SwingX, but I have trouble to find out how it works, the datepicker doesnt show.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
JXDatePicker picker = new JXDatePicker();
jLabel2.setText(picker.getDate().toString());
}
what I would like is for the picker to show when on actionperformed of a button and then write the seledted date in a jlabel. Any Ideas?
Upvotes: 2
Views: 10338
Reputation: 21223
JXDatePicker is designed as a component that combines a button, an editable field and a JXMonthView component. The user can select a date from the calendar component, which appears when the button is pressed.
So, don't forget to add your picker to the container, ie:
panel.add(picker);
Here is an example.
Upvotes: 3