//下面代码是创建的一个图片类
package com.componnt; import javax.swing.*; import java.awt.*; public class dltp extends JPanel { private Image backIcon; public dltp(Image backIcon){ this.backIcon=backIcon; } @Override public void paint(Graphics g) { g.drawImage(backIcon,0,0,this.getWidth(),getHeight(),null); } }
//我要怎么调用上面的类,让图片出现背景图片
package com.ui; import javax.swing.*; public class dljm { JFrame jf = new JFrame(); public void dl() { jf.setSize(500,300); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setResizable(false); jf.setLocationRelativeTo(null); jf.setVisible(true); } public static void main(String[] args) { new dljm().dl(); } }