/*
* Created on 2004-12-8
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.j2medev.mail;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
/**
* @author P2800
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class MainForm extends Form implements CommandListener
{
private MailClient midlet;
private TextField toField;
private TextField subField;
private boolean first = true;
public static final Command nextCommand = new Command("NEXT", Command.OK, 1);
public MainForm(MailClient midlet, String arg0)
{
super(arg0);
this.midlet = midlet;
if(first)
{
first = false;
init();
}
}
public void init()
{
toField = new TextField("To:", null, 25, TextField.ANY);
subField = new TextField("Subject:", null, 30, TextField.ANY);
this.append(toField);
this.append(subField);
this.addCommand(nextCommand);
this.setCommandListener(this);
}
public void commandAction(Command cmd,Displayable disp)
{
if(cmd == nextCommand)
{
String to = toField.getString();
String subject = subField.getString();
if(to == "" && subject == "")
{
midlet.displayAlert("Null to or sub",AlertType.WARNING,this);
}
else
{
midlet.getMessage().setTo(to);
midlet.getMessage().setSubject(subject);
midlet.getDisplay().setCurrent(midlet.getContentForm());
}
}
}
}
package com.j2medev.mail;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextBox;
import javax.microedition.midlet.MIDlet;
public class ContentForm extends TextBox implements CommandListener
{
private MailClient midlet;
private boolean first = true;
public static final Command sendCommand = new Command("SEND", Command.ITEM,
1);
public ContentForm(String arg0, String arg1, int arg2, int arg3,
MailClient midlet)
{
super(arg0, arg1, arg2, arg3);
this.midlet = midlet;
if (first)
{
first = false;
init();
}
}
public void init()
{
this.addCommand(sendCommand);
this.setCommandListener(this);
}
public void commandAction(Command cmd, Displayable disp)
{
if (cmd == sendCommand)
{
String content = this.getString();
midlet.getMessage().setContent(content);
System.out.println(midlet.getMessage());
try
{
synchronized (midlet)
{
midlet.notify();
}
} catch (Exception e)
{
}
}
}
}