问题
I am trying to use an image I made in photoshop as the background for my GUI. How do I do that? also I made some images I want to display in the button backgrounds after the action is performed...
回答1:
For the JButton, use this:
JButton button = new JButton("Button Name", new ImageIcon("foo.png");
The Panel is a bit more interesting. This is a good method, though:
ImagePanel panel = new ImagePanel(new ImageIcon("foo.png").getImage());
来源:https://stackoverflow.com/questions/8373006/using-an-image-for-the-background-of-a-jpanel-and-jbutton