my code works its just that my textarea in my message box runs out of my set window.
import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Email extends JFrame implements ActionListener { private JTextField toField; private JTextField ccField; private JTextField bccField; private JTextField subjectField; private JTextArea message; private JButton send; private JButton clear; public Email() { send = new JButton("SEND"); clear = new JButton("CLEAR"); toField = new JTextField(40); ccField = new JTextField(40); bccField = new JTextField(40); subjectField = new JTextField(40); message = new JTextArea(20,30); message.setPreferredSize(new Dimension(10,20)); JPanel toPanel = new JPanel(new BorderLayout()); JPanel ccPanel = new JPanel(new BorderLayout()); JPanel bccPanel = new JPanel(new BorderLayout()); JPanel subjectPanel = new JPanel(new BorderLayout()); JPanel messagePanel = new JPanel(new BorderLayout()); toPanel.add(new JLabel("To:"), BorderLayout.WEST); toPanel.add(toField, BorderLayout.EAST); ccPanel.add(new JLabel("CC:"), BorderLayout.WEST); ccPanel.add(ccField, BorderLayout.EAST); bccPanel.add(new JLabel("BCC:"), BorderLayout.WEST); bccPanel.add(bccField, BorderLayout.EAST); subjectPanel.add(new JLabel("Subject:"), BorderLayout.WEST); subjectPanel.add(subjectField, BorderLayout.EAST); messagePanel.add(new JLabel("Message:"), BorderLayout.WEST); messagePanel.add(message, BorderLayout.SOUTH); JPanel layout = new JPanel(new GridLayout(5,1)); layout.add(toPanel); layout.add(ccPanel); layout.add(bccPanel); layout.add(subjectPanel); JPanel buttonPanel = new JPanel(new GridLayout(1,0)); send.addActionListener(this); clear.addActionListener(this); buttonPanel.add(send); buttonPanel.add(clear); add(layout, BorderLayout.NORTH); add(messagePanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); } public void actionPerformed(ActionEvent event) { try{ if(event.getSource() == send) { if(toField.getText().contains("@")) { PrintWriter writer = new PrintWriter("email.txt"); writer.println("To: " + toField.getText()); writer.println("CC: " + ccField.getText()); writer.println("BCC: " + bccField.getText()); writer.println("Subject: " + subjectField.getText()); writer.println("Message: " + message.getText()); writer.close(); JOptionPane.showMessageDialog(null, "MESSAGE SENT!"); toField.setText(""); ccField.setText(""); bccField.setText(""); subjectField.setText(""); message.setText(""); } else JOptionPane.showMessageDialog(null, "Please enter a receipient!"); } } catch(IOException e) { } if(event.getSource() == clear) { toField.setText(""); ccField.setText(""); bccField.setText(""); subjectField.setText(""); message.setText(""); } } public static void main(String[] args) { Email win = new Email(); win.setPreferredSize(new Dimension(500,500)); win.setResizable(false); win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); win.pack(); win.setVisible(true); } }