package com.shrimpking.t14;
import javax.swing.*;
import java.awt.*;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/28 16:12
*/
class JPanelBackground extends JPanel{
Image img;
public JPanelBackground(){
ImageIcon imageIcon = new ImageIcon(JPanelBackground.class.getResource("images/pic.png"));
img = imageIcon.getImage();
}
@Override
protected void paintComponent(Graphics g)
{
g.drawImage(img,0,0,this);
}
}
public class JPanelBackgroundDemo4_19 extends JFrame
{
JPanelBackground panel;
JButton btn;
public JPanelBackgroundDemo4_19(){
panel = new JPanelBackground(); //创建对象
btn = new JButton("click");
panel.add(btn)
JPanelBackgroundDemo4_19
最新推荐文章于 2024-11-08 17:51:37 发布