rendered paste bodyimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
public class SimpleGUI extends JFrame implements ActionListener
{
private static SimpleGUI frame;
private static JMenu file;
private static JMenuItem open;
private static JMenuItem save;
private static JMenuItem exit;
private static FileWriter thefile;
private static PrintWriter output;
private static JButton button1;
private static JTextArea text;
public static void main(String[] args) throws IOException
{
frame = new SimpleGUI();
frame.setTitle("Cursed's Testing");
frame.setSize(600,700);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setVisible(true);
thefile = new FileWriter("info.txt", true);
output = new PrintWriter(thefile);
}
public SimpleGUI()
{
JMenuBar menu = new JMenuBar();
file = new JMenu("File");
open = new JMenuItem("Open");
save = new JMenuItem("Save");
exit = new JMenuItem("Exit");
button1 = new JButton("Save");
text = new JTextArea("Put info here");
add(menu, "North");
menu.add(file);
file.add(open);
file.add(save);
file.addSeparator();
file.add(exit);
add(new JScrollPane(text));
add(button1, "South");
button1.addActionListener(this);
save.addActionListener(this);
exit.addActionListener(this);
text.setBounds(25,100,200,300);
text.setWrapStyleWord(true);
text.setLineWrap(true);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == button1)
{
output.println(text.getText());
output.flush();
output.close();
}
if (e.getSource() == save)
{
output.println(text.getText());
output.flush();
output.close();
}
if (e.getSource() == exit)
{
System.exit(1);
}
}
}