⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myapplet.java

📁 教给你如何将JavaApplet程序转化为JavaApplication程序的一个范例
💻 JAVA
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -