Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作一个棋盘游戏,我在棋盘上有一个 3 x 10 的按钮。如何在按钮上添加图像图标来表示板件?
我只需要前 10 个按钮。
BufferedImage im = ImageIO.read(yourFile); ImageIcon ii = new ImageIcon(im); JButton b = ...; b.setIcon(ii);
JButton 按钮;Button=new JButton(new ImageIcon("image_path"));