import MaxFlowApplet.mf_gui.GraphFrame; import java.applet.Applet; import java.awt.*; /* The applet draws two buttons for openning and closing the "editing" window. * * When the window is opened, the option for opening a window is disabled, and * * when the window is not opened, the closing option is disabled. */ public class MFApplet extends Applet { /* Initializes the applet */ public void init() { resize(DEFAULTWIDTH, DEFAULTHEIGHT); setLayout( new FlowLayout()); add(goButton); add(endButton); endButton.disable(); } /* Responds to the user actions (button pushes) */ public boolean action(Event e, Object o) { if (e.target.equals(goButton)) { if (session == null) { session = new GraphFrame("MaxFlowApplet", this); session.init(); session.show(); session.repaint(); goButton.disable(); endButton.enable(); } return true; } if (e.target.equals(endButton)); { if (session != null) { session.hide(); session.dispose(); session = null; goButton.enable(); endButton.disable(); } return true; } } public void start() { repaint(); }; public void destroy() { if (session != null) { session.hide(); session.dispose(); } }; private static final int DEFAULTWIDTH = 350; private static final int DEFAULTHEIGHT = 70; private Button goButton = new Button("Run MaxFlowApplet"); private Button endButton = new Button("End MaxFlowApplet"); private GraphFrame session; }