/* * Created on 2004-8-2 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments *//** * @author 崔占民 * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ package HelloApplet; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.awt.Graphics; import java.net.*;public class HelloApplet extends Applet implements ActionListener { public void init () { GridLayout layout = new GridLayout (3, 4, 15, 5); setLayout (layout); Font font = new Font ("TimesRoman", Font.PLAIN, 24); setFont (font); Button button = new Button ("sun1"); button.setActionCommand ("http://www.sum.com"); button.addActionListener(this); add (button);
* Created on 2004-8-2
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*//**
* @author 崔占民
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package HelloApplet;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.awt.Graphics;
import java.net.*;public class HelloApplet extends Applet implements ActionListener
{
public void init ()
{
GridLayout layout = new GridLayout (3, 4, 15, 5);
setLayout (layout);
Font font = new Font ("TimesRoman", Font.PLAIN, 24);
setFont (font);
Button button = new Button ("sun1");
button.setActionCommand ("http://www.sum.com");
button.addActionListener(this);
add (button);
button = new Button ("sun2");
button.setActionCommand ("http://www.sum.com");
button.addActionListener (this);
add (button);
button = new Button ("sun3");
button.setActionCommand ("http://www.sum.com");
button.addActionListener (this);
add (button);
button = new Button ("sun4");
button.setActionCommand ("http://www.sum.com");
button.addActionListener (this);
add (button);
button = new Button ("sun5");
button.setActionCommand ("http://www.sum.com");
button.addActionListener (this);
add (button);
button = new Button ("sun6");
button.setActionCommand ("http://www.sum.com");
button.addActionListener (this);
add (button);
button = new Button ("sun7");
button.setActionCommand ("http://www.sum.com");
button.addActionListener (this);
add (button); button = new Button ("汉字");
button.setActionCommand ("http://www.sum.com");
button.addActionListener (this);
add (button);
}
public void paint (Graphics g)
{
g.drawString ("Hello World!", 0, 50);
}
public void actionPerformed (ActionEvent event)
{
String pageName = event.getActionCommand ();
try
{
URL url = new URL (pageName);
AppletContext context = getAppletContext ();
context.showDocument (url);
}
catch (MalformedURLException e)
{
repaint ();
}
}
}
想学学都学不到……