📄 ativebutton.java
字号:
import java.awt.*;import java.applet.*;import javax.swing.*;import java.net.*;public class AtiveButton extends Applet { //创建改变背景与前景颜色的按钮 ChangeBgButton changeBgButton = new ChangeBgButton("改背景颜色的按钮"); ChangeIconButton changeIconButton; String[] iconFileNames = {"1.gif", "2.gif"}; ImageIcon[] icons = new ImageIcon[2]; //Applet的初始化方法 public void init() { try {jbInit();} catch(Exception e) {} } //被初始化方法引用的方法 private void jbInit() throws Exception { this.setLayout(null); //建立动态按钮的图标 for(int i = 0; i < 2; ++i){ icons[i] = new ImageIcon(new URL(this.getCodeBase() + iconFileNames[i])); } //创建改变按钮图标的按钮 changeIconButton = new ChangeIconButton("",icons); //设置按钮的位置与大小 changeBgButton.setBounds(new Rectangle(30, 35, 138, 29)); changeIconButton.setBounds(new Rectangle(200, 25, 50, 50)); //向Applet加入按钮 this.add(changeBgButton); this.add(changeIconButton); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -