I'm currently working on a Eclipse to build a java swing app. I'm having problems displaying my database data into an observing text field. The observing text field is used with a date picker for the user to select the date they want, which will then be saved into the database as a string, e.g. 2014/07/03. After adding this date record to the database, I want to be able to display it before the user can update changes to the date. I tried using the .setText() method but my data is not displaying.
final ObservingTextField txtDutyDate = new ObservingTextField();
txtDutyDate.setColumns(10);
txtDutyDate.setBounds(283, 427, 108, 22);
add(txtDutyDate);
txtDutyDate.setText(d.getDutyDate());
P.S ObservingTextField is a self-declared class so I can put the date in the textbox after selecting it from the calendar
public class ObservingTextField extends JTextField implements Observer {
/**
*
*/
private static final long serialVersionUID = 1L;
public void update(Observable o, Object arg) {
Calendar calendar = (Calendar) arg;
DatePicker dp = (DatePicker) o;
// System.out.println("picked=" + dp.formatDate(calendar));
setText(dp.formatDate(calendar));
}
}