import javax.swing.JFrame; import java.awt.BorderLayout; import javax.swing.JButton; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JTextField; import java.text.DateFormat; import java.util.Date; public class UndoFrame extends JFrame implements ActionListener{ private UndoTextArea textField=null; private JButton undoButton=null; private JButton enterButton=null; private JTextField dateField=null; int counter; public UndoFrame(){ textField=new UndoTextArea(20,20); undoButton=new JButton("Undo"); JButton saveButton=new JButton("Save"); undoButton.addActionListener(this); saveButton.addActionListener(this); dateField=new JTextField(20); getContentPane().add(textField,BorderLayout.CENTER); getContentPane().add(dateField,BorderLayout.SOUTH); getContentPane().add(undoButton,BorderLayout.WEST); getContentPane().add(saveButton,BorderLayout.EAST); pack(); setVisible(true); addWindowListener(new WindowCloser()); } // Implementation of java.awt.event.ActionListener public void actionPerformed(ActionEvent actionEvent) { if (actionEvent.getSource()==undoButton) textField.undo(); else textField.setText(textField.getText()); dateField.setText(DateFormat.getTimeInstance().format( new Date(System.currentTimeMillis()))); } public static void main(String [] args){ UndoFrame uf=new UndoFrame(); } }