myapplet.java

来自「教给你如何将JavaApplet程序转化为JavaApplication程序的一」· Java 代码 · 共 38 行

JAVA
38
字号
// written by : Christine Amarra
// December 15, 2004

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MyApplet extends JApplet
{
	private DrawingCanvas canvas = null;
	JButton button = null;
	
	//initialize components here
	public void init()
	{
		Container c = this.getContentPane();
		
		button = new JButton("Click Me");
		c.add(button, "North");
		//The old way of doing action listeners on buttons...
		//button.addActionListener(this);
		//Don't forget to define actionPerformed();
		
		//The new way of doing action listeners on buttons...
		button.addActionListener( new ActionListener()
								{
								   //anonymous inner class for WindowAdapter
									public void actionPerformed( ActionEvent ae )
									{
										System.out.println("Clicked!");
									}
								});
		//we'll be discussing more on this next year... :)
		
		canvas = new DrawingCanvas();
		c.add(canvas);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?