用个JLabel
JLabel(Icon image);
再把这个JLabel用add加到JPanel里.

解决方案 »

  1.   

    你如果实在想这么干的话,当然也没问题,JPanel是javax.swing.JComponent的子类,所以你可以重载这个方法:
    public void paintComponent(Graphics g);
    不过这么做实在是不太厚道,画图没问题,其它的就不保证了.
      

  2.   

    class BackgroundPanel extends JPanel {
        BorderLayout borderLayout1 = new BorderLayout();
        ImageIcon icon;    public BackgroundPanel() {
            this.setLayout(borderLayout1);
            icon = new ImageIcon(BackgroundPanel.class.getResource("bg.jpg"));
            this.setPreferredSize(new Dimension(467, 362));
        }    public void paintComponent(Graphics g) {
            g.drawImage(icon.getImage(), 0, 0, this);
        }
    }
      

  3.   

    public void paintComponent(Graphics g)
    这个方法是要用的/
      

  4.   

    我几个又个Canvas,可以用来画图得!是吗?能给个实例吗/
      

  5.   

    谁去把这个分给领了啊!
    http://community.csdn.net/Expert/topic/3861/3861006.xml?temp=.9839289
    谢谢
      

  6.   

    ImageIcon icon = new ImageIcon();
    drawImage(icon.getImage());
    具体参数多看看文档,对你有益处的。。