import javax.swing.*; import java.awt.*; import java.awt.event.*; public class GUI extends JFrame implements ActionListener { private Template letterTemplate; private JButton loadTemplate = new JButton("Load Template"); private JTextArea text = new JTextArea(); private JLabel info = new JLabel(); private JButton saveTemplate = new JButton("Save"); public GUI() { letterTemplate = new Template("Default"," Dear ,\n\n" + " Thank you very much for ordering from us on . We recently received" + "several\n thousand cans of the very special ingredient, which has" + "returned from a luxurious trip to Hawaii, and we can\n make a" + "one-time offer of just US$99.99 per case. If you are interested," + " just call 1-800-555-1234 or click to:\n\thttp://www.TheHappyViking.com/SpecialOrder/" +"/order.html\nIf you contact us by phone, mention special order #" +" to get this extra special discount.\n\nThanks again from all of" + " us at The Happy Viking. We hope you have many days and nights enjoying this\nwonderful delicacy."); text.append("\tNew Template\t\n\n\n"); text.setSize(800,1000); info.setText("To define an area of text to replace include the text in < >"); getContentPane().setLayout(new FlowLayout()); getContentPane().add(loadTemplate); getContentPane().add(info); getContentPane().add(text); getContentPane().add(saveTemplate); saveTemplate.addActionListener(this); loadTemplate.addActionListener(this); } public void actionPerformed(ActionEvent e){ if(e.getSource() == saveTemplate) text.setText("Save"); if(e.getSource()==loadTemplate) text.setText(letterTemplate.getContent()); } /* public static void main(String args[]) { GUI myGui = new GUI(); myGui.setSize(600, 600); myGui.setVisible(true); return; } */}