📄 appletparameterdemo.java
字号:
package applet;
import java.awt.*;
import java.applet.*;
public class AppletParameterDemo extends Applet {
Button parameterBtn = new Button();
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
//取得文字参数
String name = this.getParameter("btnText");
//取得背景参数
String bgColor = this.getParameter("bgColor");
//取得文字颜色参数
String fgColor = this.getParameter("fgColor");
try{
//设置按钮的文字
parameterBtn.setLabel(name);
//设置按钮背景颜色
parameterBtn.setBackground(new Color(Integer.parseInt(bgColor)));
//设置按钮文字颜色
parameterBtn.setForeground(new Color(Integer.parseInt(fgColor)));
}catch(Exception el){
el.printStackTrace();
}
//加入按钮
this.add(parameterBtn);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -