java awt 怎样给textAreat添加背景图片

解决方案 »

  1.   

    也许awt不能,swing的可以。但是你的Swing控件是可以和awt一起工作的。public void setBack() { 
    ((JPanel) this.getContentPane()).setOpaque(false); 
    // Winter.jpg这个图片的位置要跟当前这个类是同一个包下 
    URL url = "当前这个类的名字".class.getResource("Winter.jpg"); 
    ImageIcon img = new ImageIcon(url); 
    JLabel background = new JLabel(img); 
    this.getLayeredPane().add(background, new Integer(Integer.MIN_VALUE)); 
    background.setBounds(0, 0, img.getIconWidth(), img.getIconHeight()); 
    }