826220679@qq.com
2025-08-09 a8a90fd2d5040e66cc66b3da122a7f82561ff6f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package window;
 
import java.awt.Graphics;
import java.awt.Image;
 
import javax.swing.ImageIcon;
import javax.swing.JPanel;
 
@SuppressWarnings("serial")
public class BackgroundPanel extends JPanel {
    private Image backgroundImage;
 
    public BackgroundPanel() {
        ImageIcon icon = new ImageIcon("systemfile/bg.jpg");
        if (icon.getImage() != null) {
            backgroundImage = icon.getImage();
        }
    }
 
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (backgroundImage != null) {
            g.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), this);
        }
    }
}