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

📄 validateapplet.java

📁 java2图形设计卷1:awt 源码
💻 JAVA
字号:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class ValidateApplet extends Applet {
	private GrayPanel grayPanel = new GrayPanel();
	public void init() {
		add(grayPanel);		
	}
}
class GrayPanel extends Panel implements ActionListener {
	private TextField  field    = new TextField("TextField");
	private Button     lgButton = new Button   ("larger font");
	private Button     smButton = new Button   ("smaller font");

	public GrayPanel() {
		lgButton.addActionListener(this);
		smButton.addActionListener(this);

		add(field);		
		add(lgButton);
		add(smButton);
		setBackground(Color.gray);
	}
	public void actionPerformed(ActionEvent event) {
		Button button  = (Button)event.getSource();
		Font   curFont = field.getFont();
		int    newSize = curFont.getSize();

		if(button == lgButton) newSize += 3;
		if(button == smButton) newSize -= 3;

		field.setFont(new Font(curFont.getFamily(),
		                       curFont.getStyle(), newSize));
	}
	public void paint(Graphics g) {
		g.setColor(Color.black);
		g.drawRect(0,0,getSize().width-1,getSize().height-1);
	}
}

⌨️ 快捷键说明

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