package date;
/*
* DateInputDemo.java
*/
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class DateInputDemo extends JFrame{
private JButton btnOK;
private SpinnerDateModel model;
private JSpinner input;
public DateInputDemo(){
super("Datum Eingabe");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("Datum:");
JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
model = new SpinnerDateModel();
input = new JSpinner(model);
input.setEditor(new JSpinner.DateEditor(input, "dd MMM yyyy"));
input.setPreferredSize(new Dimension(120,20));
panel.add(label);
panel.add(input);
btnOK = new JButton("OK");
panel.add(btnOK);
getContentPane().add(panel);
pack();
btnOK.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
inputActionPerformed(e);
}
});
}
private void inputActionPerformed(final ActionEvent e){
Date value = model.getDate();
System.out.println(value);
}
public static void main(final String args[]){new DateInputDemo().setVisible(true);}
}