import java.awt.FlowLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Main extends JFrame{
private JPanel imagePanel;
private ImageIcon background;
public static void main(String[] args) {
new Main();
}
public Main() {
background = new ImageIcon("yourPic.jpg");
JLabel label = new JLabel(background);
label.setBounds(0, 0, background.getIconWidth(),background.getIconHeight());
imagePanel = (JPanel) this.getContentPane();
imagePanel.setOpaque(false);
imagePanel.setLayout(new FlowLayout());
imagePanel.add(new JButton("测试按钮"));
getLayeredPane().add(label, Integer.MIN_VALUE);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(background.getIconWidth(), background.getIconHeight());
setVisible(true);
}
}