📄 appletapp.txt
字号:
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class AppletApp extends Applet implements ActionListener{
static int i=10;
//TextArea ta;
Button b1;
Button b2;
Font f=new Font("TimesRoman",Font.PLAIN,10);
//ta.setFont(f);
public void init()
{//ta=new TextArea("hello!this is my applet program.",15,50);
// AppletApp app=new AppletApp();
//Panel p=new Panel();
// app.add(p);
// Font f=new Font("TimesRoman",Font.PLAIN,10);
// ta.setFont(f);
// TextArea ta;
// Button b1,b2;
b1=new Button("放大");
b2=new Button("缩小");
add(b1);
add(b2);
// add(ta);
setBackground(Color.blue);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void paint(Graphics g)
{Font f =new Font("TimesRoman",Font.PLAIN,i);
g.setFont(f);
g.drawString("hello!this is my applet program.",50,200);}
public void actionPerformed(ActionEvent e)
{//static int i=10;
//ta.setText(e.getActionCommand());
if(e.getActionCommand()=="放大")
{i=i+2;
// Font f1=new Font("TimesRoman",Font.PLAIN,i);
// ta.setFont(f1);
repaint();}
if(e.getActionCommand()=="缩小")
{i=i-2;
// Font f2=new Font("TimesRoman",Font.PLAIN,i);
// ta.setFont(f2);
repaint();}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -