import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Veep extends JFrame { //Constructor takes no arguments public Veep() { super("VeeP - Very Easy Email Program"); //define all the gui elements and add them to the Veep object Container contentPane = getContentPane(); //menu bar JMenuBar bar = new JMenuBar(); //File Menu JMenu fileMenu = new JMenu("File"); JMenuItem send = new JMenuItem("Send"); JMenuItem receive = new JMenuItem("Receive"); JMenuItem exit = new JMenuItem("Exit"); fileMenu.add(send); fileMenu.add(receive); fileMenu.add(exit); send.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VeepSend sender = new VeepSend(); } } ); receive.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VeepReceive receiver = new VeepReceive(); } } ); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } } ); //Options Menu JMenu optionMenu = new JMenu("Options"); JMenu appearanceMenu = new JMenu("Appearance"); optionMenu.add(appearanceMenu); JMenuItem metal = new JMenuItem("Metal"); JMenuItem motif = new JMenuItem("Motif"); JMenuItem windows = new JMenuItem("Windows"); LnFListener lnfListener = new LnFListener(this); metal.addActionListener(lnfListener); motif.addActionListener(lnfListener); windows.addActionListener(lnfListener); appearanceMenu.add(metal); appearanceMenu.add(motif); appearanceMenu.add(windows); //Help Menu JMenu helpMenu = new JMenu("Help"); JMenuItem about = new JMenuItem("About Veep"); helpMenu.add(about); about.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null,"Veep - Very Easy Email Program\nVersion 0.3.0\nCopyright Tom Martin 2001\nReleased under the GPL on\n04/02/2001","VeeP",JOptionPane.INFORMATION_MESSAGE); } } ); //add the menus to the Veep object bar.add(fileMenu); bar.add(optionMenu); bar.add(helpMenu); setJMenuBar (bar); //Define the toolbar JToolBar jtb = new JToolBar(); SendAction sendButton = new SendAction(this); jtb.add(sendButton); ReceiveAction receiveButton = new ReceiveAction(this); jtb.add(receiveButton); contentPane.add(jtb, BorderLayout.NORTH); //Define the Desktop final JDesktopPane desktop = new JDesktopPane(); contentPane.add(desktop,BorderLayout.CENTER); //set the opening size for the window and remember to draw it setSize (800,600); show(); } //Main method - nothing much to see here public static void main(String args[]) { Veep app = new Veep(); app.addWindowListener(new WindowAdapter() { public void windowClosing (WindowEvent e) { System.exit(0); } } ); } //Create the pop-up frame for sending an email class VeepSend extends JFrame { private String host, from, rcpt, portNo, message; private int port; private JTextField hostInput, fromInput, rcptInput, portInput; private JLabel hostLabel, portLabel, fromLabel, rcptLabel,messageLabel; private JButton sendButton; private JTextArea messageInput; public VeepSend() { Container c = getContentPane(); c.setLayout (new FlowLayout()); hostLabel = new JLabel ("Enter mail host : "); portLabel = new JLabel ("Enter port no : "); fromLabel = new JLabel ("Send From : "); rcptLabel = new JLabel("Send To : "); messageLabel = new JLabel("Message : "); hostInput = new JTextField(25); portInput = new JTextField("25",25); fromInput = new JTextField(25); rcptInput = new JTextField(25); messageInput = new JTextArea(10,25); sendButton = new JButton ("Send"); c.add(hostLabel); c.add(hostInput); c.add(portLabel); c.add(portInput); c.add(fromLabel); c.add(fromInput); c.add(rcptLabel); c.add(rcptInput); c.add(messageLabel); c.add(messageInput); c.add(sendButton); VeepHandler handler = new VeepHandler(); sendButton.addActionListener(handler); addWindowListener(new WindowAdapter() { public void windowClosing (WindowEvent e) { ; } } ); setSize (350, 500); show(); } private class VeepHandler implements ActionListener { public void actionPerformed (ActionEvent e) { if (e.getSource() == sendButton) { host = hostInput.getText(); portNo = portInput.getText(); port = Integer.parseInt(portNo); from = fromInput.getText(); rcpt = rcptInput.getText(); message = messageInput.getText(); SmtpClient sender = new SmtpClient(port,host); sender.from(from); sender.rcpt(rcpt); sender.message(message); sender.quit(); messageInput.setText("Message Sent."); } } } } //create the pop-up for checking mail class VeepReceive extends JFrame { private String host, user, pass,portNo; private int port; private JTextField hostInput, userInput, portInput; private JTextArea response; private JPasswordField passInput; private JLabel hostLabel, portLabel, userLabel, passLabel; private JButton connectButton; public VeepReceive() { super ("VeeP - the Very Easy Email Program"); Container c = getContentPane(); c.setLayout (new FlowLayout()); hostLabel = new JLabel ("Enter mail host : "); portLabel = new JLabel ("Enter port no : "); userLabel = new JLabel ("Enter username : "); passLabel = new JLabel("Enter password : "); hostInput = new JTextField(25); portInput = new JTextField("110",25); userInput = new JTextField(25); passInput = new JPasswordField(25); response = new JTextArea(10,25); connectButton = new JButton ("Connect"); c.add(hostLabel); c.add(hostInput); c.add(portLabel); c.add(portInput); c.add(userLabel); c.add(userInput); c.add(passLabel); c.add(passInput); c.add(connectButton); c.add(response); TextFieldHandler handler = new TextFieldHandler(); connectButton.addActionListener(handler); addWindowListener(new WindowAdapter() { public void windowClosing (WindowEvent e) { ; } } ); setSize (375, 500); show(); } private class TextFieldHandler implements ActionListener { public void actionPerformed (ActionEvent e) { if (e.getSource() == connectButton) { host = hostInput.getText(); portNo = portInput.getText(); port = Integer.parseInt(portNo); user = userInput.getText(); String s = new String (passInput.getPassword()); pass = s; PopClient popper = new PopClient(port,host); popper.connect(user,pass); String storeText = "Connected to "+host+"\nRetreiving message list..."; response.setText(storeText); popper.listMessages(); String no_of_messages = popper.getNoOfMessages(); int k = Integer.parseInt(no_of_messages); if(k == 1) { storeText = storeText+"\nYou have "+no_of_messages+"message."; } else { storeText = storeText+"\nYou have "+no_of_messages+"messages."; } for (int i=0;i