email me at borlaj@portlandschools.org

Loading
notes previous (10/<10) submit the dump links  
 

Group project

 

In groups of 2 you are going to do pair programming. , you are going to create a email application (cant be applet, for security reasons). That will have at a minimum a to field a subject and message and then send that to the receipt. Start with code below


import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
/**
 * Class Test - write a description of the class here
 * 
 * @author (your names) 
 * @version (a version number)
 */
public class MailProgram extends JFrame implements ActionListener  
{
    // instance variables - replace the example below with your own
    private int x;
    //We have 3 swing components that we must declare up here, so every method has access to them
    JTextField textField = new JTextField(20);
    JButton lowerCase= new JButton ("To Lower");
    JButton upperCase = new JButton ("To Upper");
    /**
     * Called by the browser or applet viewer to inform this JApplet that it
     * has been loaded into the system. It is always called before the first 
     * time that the start method is called.
     */
    public void init()
    {
        Container screen = getContentPane();
        screen.setBackground(Color.green);
        screen.setLayout (new FlowLayout() );
        screen.add(textField);
        screen.add(lowerCase);
        screen.add(upperCase);

        lowerCase.addActionListener(this); 
        upperCase.addActionListener(this);
    }

    /**
     * Paint method for applet.
     * 
     * @param  g   the Graphics object for this applet
     */
    public void paint(Graphics g)
    {
        super.paint(g);
    }

    public void actionPerformed(ActionEvent thisEvent)
    {
        Object source = thisEvent.getSource();

        if (source == lowerCase)
        {           
            String text=textField.getText();
            String lower=text.toLowerCase();
            textField.setText(lower);
        }
        if (source == upperCase)
        {
            String text=textField.getText();
            String caps=text.toUpperCase();
            textField.setText(caps);
        }
    }

    public static void main(String[] args) 
    {
        MailProgram m = new MailProgram();
        m.init();
        m.setSize(520,520);
        m.setVisible(true);

    }
}


            

Day2:

Continue with that and buffergraphics and mouse dragged. So now the user can sign his email and send that as an attachment.

 

Advanced:

Ideas, add the ability to send an attachment. Add a way for user to put in their username/password. Send an image of someones drawing. Break up a short message in to many messages (like if the message is I LOVE YOU it would send each letter as a message.)

 

Additional Gmail account:

user:deeringcs2@gmail.com

password: mrborland