icons.java

来自「21天学JAVA源代码」· Java 代码 · 共 25 行

JAVA
25
字号
import javax.swing.*;

public class Icons extends JFrame {
    JButton[] buttons = new JButton[24];

    public Icons() {
        super("Icons");
        setSize(335, 318);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel pane = new JPanel();
        ImageIcon icon = new ImageIcon("3dman.gif");
        for (int i = 0; i < 24; i++) {
            buttons[i] = new JButton(icon);
            pane.add(buttons[i]);
        }
        setContentPane(pane);
        show();
    }

    public static void main(String[] arguments) {
        Icons ike = new Icons();
    }
}

⌨️ 快捷键说明

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