使用图像作为JPanel和JButton的背景
我试图使用我在photoshop中制作的图像作为GUI的背景。 我怎么做? 我也做了一些想要在动作执行后在按钮背景中显示的图像……
对于JButton,请使用:
JButton button = new JButton("Button Name", new ImageIcon("foo.png");
小组更有趣。 不过这是一个很好的方法:
ImagePanel panel = new ImagePanel(new ImageIcon("foo.png").getImage());