| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 498 人关注过本帖
标题:[原创]如何制作透明组件。
只看楼主 加入收藏
xiuyuan123
Rank: 2
等 级:新手上路
威 望:3
帖 子:140
专家分:0
注 册:2006-4-25
收藏
 问题点数:0 回复次数:1 
[原创]如何制作透明组件。

懒得写说明了,大家应该能看懂。这是一个透明面板的例子,可仿此法制作其它透明组件。

希望与大家分享经验。

package com.borland.samples.welcome;

import java.awt.*;
public class MyPanel extends Panel {
private Image bi; // offscreen image
private Graphics big; // Graphics for the offscreen image
public void update(Graphics g) {
paint(g);
}
public void paint(Graphics g) {
if (bi == null) { // you can't do this from the constructor
bi = createImage(getSize().width,getSize().height);
big = bi.getGraphics();
}
Rectangle area = g.getClipBounds(); // this is the area that needs to be (re)painted (no need to repaint everything)
big.setClip(area);
big.clearRect(area.x, area.y, area.width, area.height); // fills the area with the background color // the next statement will call the paint methods for the other panels/components you have added to this panel // and draw them to the offscreen image
super.paint(big);// now draw the offscreen image to the panel
g.drawImage(bi,area.x, area.y, area.x+area.width, area.y+area.height,area.x, area.y, area.x+area.width, area.y+area.height,this);
}
}

搜索更多相关主题的帖子: 组件 制作 
2006-06-21 11:19
yangwudong
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:244
专家分:0
注 册:2005-8-18
收藏
得分:0 
怎么放到j2ee里面了啊?应该是在java里面啊!

别做程序了,给你们一个赚钱的秘诀。做豆腐;if 做硬了 then 卖豆腐干;if 做稀了 then 卖豆腐花;if 太稀了 then 卖豆浆;if 豆腐卖不动了放几天 then 卖臭豆腐; else if 还卖不动放坏了 then 卖腐乳;
2006-06-21 17:33
快速回复:[原创]如何制作透明组件。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018094 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved