0

我正在制作一个棋盘游戏,我在棋盘上有一个 3 x 10 的按钮。如何在按钮上添加图像图标来表示板件?

我只需要前 10 个按钮。

4

2 回答 2

1
BufferedImage im = ImageIO.read(yourFile);
ImageIcon ii = new ImageIcon(im);
JButton b = ...;
b.setIcon(ii);
于 2012-04-10T19:23:31.967 回答
0

JButton 按钮;Button=new JButton(new ImageIcon("image_path"));

于 2014-07-13T10:48:37.973 回答