Creating JBiff
JBiff will not take much code, so we can define it in a single
class in a single file. As we will see, that is a fib; we will need
another small class to handle a mouse event on the window’s “kill”
button, but more on that later. It is generally good OO style to
separate the GUI from the logic, but we won’t get too hung up on that.
Now, to structure the class: as with any Java class, we will have to
create a constructor. The constructor creates an instance of the JBiff
class and shows the basic GUI. The class’s main ()
method is where the action takes places; it will connect to an IMAP
server, retrieve the information, and then cause it to be displayed in
the GUI.
The first thing that we need to do is import references to the various Java packages that we will be using—some from JAF and the Java Mail API and others from the more mundane java.awt and java.util packages in the core. Those classes in the javax. mail package are in Java Mail API. Those in the javax.activation package are part of the JAF.
import javax.mail.*; import javax.mail.event.*; import javax.mail.internet.*; import javax.activation.*; import java.util.*; import java.awt.*; import java.awt.event.*;
Our class represents the JBiff GUI; all of the logic is in the
main ()
method. To make things easy, we will have our
GUI class extend Frame, which will create a frame when the class is
instantiated. We will also need a label on which to write our mailbox status message. The class starts this way:
public class ...
Get Programming Internet Email now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.