I want to develop a Swing desktop application with jlabel, JDateChooser and a submit button.
I am using below code :
public class Homeg {
public static void main(String args[]) {
JFrame frame=new JFrame("date display");
JDatePickerImpl datePicker;
UtilDateModel model = new UtilDateModel();
model.setDate(1990, 8, 24);
model.setSelected(true);
JDatePanelImpl datePanel = new JDatePanelImpl(model,null);
datePicker = new JDatePickerImpl(datePanel, null);
frame.setLayout(new FlowLayout());
JLabel label=new JLabel("Date");
JButton submit=new JButton("SUBMIT");
frame.add(label);
frame.add(datePicker);
frame.add(submit);
frame.setSize(400,400);
frame.setVisible(true);
}
}
And it is giving output having only JDatechooser.
Instead I wanted a output which must have a JLabel, JDatePicker and a submit button. Here it is showing only JDatePicker.
You should always call pack() before making a call to setVisible();
Then to actuall make the date the submit button submit the date use: