java中的frame如何添加背景图片,窗口中加了面板,或者直接在面板中添加图片,面板不识现切换,求详细的

过程和原理

代码供参考

public class Demo extends JFrame {
 JLabel jl =new JLabel();
 public Demo() {
  jl =new JLabel(new ImageIcon("bg.jpg"));
  this.add(jl);
  this.setSize(300, 200);
  this.setVisible(true);
  this.setDefaultCloseOperation(EXIT_ON_CLOSE);
 }
 public static void main(String[] args){
  new Demo();
 }
}

温馨提示:答案为网友推荐,仅供参考
相似回答