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

📄 button2newb.java

📁 翁剀JAVA语言那门课程的教案 很多人都看多他的视频教程可惜没有ppt的教案
💻 JAVA
字号:
//: Button2NewB.java
// An application and an applet
import java.awt.*;
import java.awt.event.*; // Must add this
import java.applet.*;

public class Button2NewB extends Applet {
	Button
		b1 = new Button("Button 1"),
		b2 = new Button("Button 2");
	TextField t = new TextField(20);
	
	public void init() {
		b1.addActionListener(new B1());
		b2.addActionListener(new B2());
		add(b1);
		add(b2);
		add(t);
	}
	
	class B1 implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			t.setText("Button 1");
		}
	}

	class B2 implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			t.setText("Button 2");
		}
	}

	// To close the application:
	static class WL extends WindowAdapter {
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	}

	// A main() for the application:
	public static void main(String[] args) {
		Button2NewB applet = new Button2NewB();
		Frame aFrame = new Frame("Button2NewB");
		aFrame.addWindowListener(new WL());
		aFrame.add(applet, BorderLayout.CENTER);
		aFrame.setSize(300,200);
		applet.init();
		applet.start();
		aFrame.setVisible(true);
	}
} ///:~

//	<applet code=Button2NewB.class width=200 height=100></applet>

⌨️ 快捷键说明

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