import java.applet.*; import java.awt.*; import java.awt.event.*; import java.net.*; import javax.swing.*; public class ShowURLApplet extends JApplet implements ActionListener { public void actionPerformed(ActionEvent event) { this.handle_button(); } // actionPerformed private void handle_button() { try { URL yahoo_url = new URL("http://www.yahoo.com/"); getAppletContext().showDocument(yahoo_url); } // try catch (java.net.MalformedURLException e) { // Fel på webbadressen } } // handle_button public void init() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); JButton button = new JButton("Ladda YAHOO-sida"); button.addActionListener(this); cp.add(button); } // init } // ShowURLApplet