java

位置:IT落伍者 >> java >> 浏览文章

java 伪半透明 JTrxtArea


发布日期:2019年05月01日
 
java 伪半透明 JTrxtArea

说明: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);

}

}

上一篇:面向Java开发人员的Scala指南: 面向对象的函数编程

下一篇:Java网络编程 多种多样的连接数据库的方式