📄 fonttest.java
字号:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class FontTest extends Applet implements ActionListener
{
Button Btn1,Btn2,Btn3,Btn4;
TextField text1;
TextArea text2;
Font f1,f2,f3,f4,f5;
Toolkit toolkit1;
public void init()
{
f1=new Font("Hei",Font.PLAIN,18);
f1=new Font("Hei",Font.BOLD,10);
f1=new Font("Hei",Font.ITALIC,12);
f1=new Font("Courier",Font.PLAIN,12);
f1=new Font("TimesRoman",Font.BOLD+Font.ITALIC,14);
toolkit1=getToolkit();
text1=new TextField(15);
text2=new TextArea(15,15);
Btn1=new Button("保存");
Btn1.setBackground(Color.red);
Btn1.setForeground(Color.blue);
Btn2=new Button("确定");
Btn2.setFont(f2);
Btn1.setBackground(Color.blue);
Btn1.setForeground(Color.red);
Btn3=new Button("老猫");
Btn3.setForeground(Color.red);
text1.setBackground(Color.cyan);
text1.setForeground(Color.red);
text2.setBackground(Color.green);
text2.setForeground(Color.yellow);
text2.setFont(f3);
add(text1);
add(Btn1);
add(Btn2);
add(Btn3);
add(text2);
Btn1.addActionListener(this);
Btn2.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==Btn2)
{
for(int i=0;i<=2;i++)
{
toolkit1.beep();
Btn1.setFont(f4);
Btn1.setForeground(Color.red);
Btn1.setBackground(Color.green);
Btn1.setSize(60,40);
text1.setVisible(false);
text2.setForeground(Color.red);
text2.setFont(f5);
}
}
else if(e.getSource()==Btn3)
{
for(int i=0;i<=6;i++)
{
toolkit1.beep();
Btn1.setFont(f4);
Btn1.setBackground(Color.green);
Btn1.setForeground(Color.red);
Btn1.setSize(40,60);
text1.setVisible(true);
text2.setForeground(Color.blue);
Btn1.setBackground(Color.red);
text2.setFont(f1);
text1.setLocation(120,200);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -