import java.awt.*; // Java GUI classes import java.applet.*; import java.awt.event.*; import java.net.*; class MyFrame extends Frame implements ActionListener { public MyFrame(Applet applet) { super("Example Applet"); MenuBar menubar = new MenuBar(); // make a menu with Quit Menu file = new Menu("File",true); menubar.add(file); file.add("Quit"); setMenuBar(menubar); file.addActionListener(this); add("Center",applet); setSize(300,300); applet.init(); // start applet this.show(); } public void actionPerformed (ActionEvent evt) { String arg = evt.getActionCommand(); if (arg.equals("Quit")) { // if Quit, exit System.exit(0); } } } public class MyApplet1 extends Applet implements ActionListener { // to run: java MyApplet1 public static void main(String args[]) { Applet applet = new MyApplet1(); // create the applet and Frame frame = new MyFrame(applet); // put it into a frame } private Button myButton; public void init() { setLayout(null); AppletInit.myString = "HELLO FROM APPLET1"; myButton = new Button("Next Applet"); myButton.setBounds(100,100,100,25); add(myButton); myButton.addActionListener(this); } public void actionPerformed(ActionEvent event) { String s = event.getActionCommand(); if (s.equals("Next Applet")) { AppletContext ac = getAppletContext(); try { ac.showDocument(new URL("http://www.mcs.csueastbay.edu/~billard/se/cs4310/stock/MyApplet2.html")); } catch (Exception e) {showStatus("URL not found");} } } }