说明:java将gif设置为icon是原本透明的地方还是透明的先做一张半透明的图片存储为gif
然后用它填充一个大的图 相当于半透明的背景
/**
*
* @author SAMSUNG
*/
import javaxswingImageIcon;
import javaxswingJPanel;
import javaxswingJLabel;
import javaxswingJTextArea;
/*
* /galuodo
*/
public class GTextArea extends JPanel {
JTextArea tex = null;
JLabel bg;
ImageIcon imageIcon = null;
public GTextArea() {
setLayout(null);
bg = new JLabel();
imageIcon = new ImageIcon(??gif);
tex = new JTextArea();
bgsetIcon(imageIcon);
texsetSize( );//
bgsetSize( );//图片要和文本一样大
texsetOpaque(false);//文本设置透明否则就没有效果了
bgsetLocation( );
texsetLocation( );//位置应该一样
add(tex);//注意顺序
add(bg);
setOpaque(false);
thissetVisible(true);
}
}