I'm trying to replace a JTextField with a date picker field, I've followed the installation instructions I was able to find as well as other examples here on SO. Also, I have the latest version (v1.3.4) - https://sourceforge.net/projects/jdatepicker/
//...
import org.jdatepicker.impl.JDatePanelImpl;
import org.jdatepicker.impl.JDatePickerImpl;
import org.jdatepicker.impl.UtilDateModel;
public class NewTransactionDialog extends JDialog {
private JPanel panel = new JPanel(new GridLayout(0, 1));
//...
public NewTransactionDialog() {
//...
// date
panel.add(new JLabel("Date:"));
// panel.add(new JTextField()); // old text field i want to replace
UtilDateModel model = new UtilDateModel();
JDatePanelImpl datePanel = new JDatePanelImpl(model, null);
JDatePickerImpl datePicker = new JDatePickerImpl(datePanel, null);
panel.add(datePicker);
//...
getContentPane().add(panel);
pack();
}
}
Apologies if this is just some dumb error but I can't see from my side what I've done wrong this time. I did have to add the second NULL arguments coz Eclipse was telling me that the constructors didn't match. This seemed different from every example I say which only had the one arguments passed to the constructors (JDatePanelImpl, JDatePickerImpl) - should these be passed as something other than NULL?
The errors thrown in the eclipse console are:7
Exception in thread "main" java.lang.NullPointerException
at org.jdatepicker.impl.JDatePanelImpl$InternalView.getPreviousMonthButton(JDatePanelImpl.java:517)
at org.jdatepicker.impl.JDatePanelImpl$InternalView.getPreviousButtonPanel(JDatePanelImpl.java:442)
at org.jdatepicker.impl.JDatePanelImpl$InternalView.getNorthPanel(JDatePanelImpl.java:251)
at org.jdatepicker.impl.JDatePanelImpl$InternalView.initialise(JDatePanelImpl.java:234)
at org.jdatepicker.impl.JDatePanelImpl$InternalView.<init>(JDatePanelImpl.java:222)
at org.jdatepicker.impl.JDatePanelImpl.<init>(JDatePanelImpl.java:110)
at biz.martyn.budget.NewTransactionDialog.<init>(NewTransactionDialog.java:54)
at biz.martyn.budget.TransactionsToolbar.<init>(TransactionsToolbar.java:34)
at biz.martyn.budget.Budget.main(Budget.java:39)