如何制作透明组件。
懒得写说明了,大家应该能看懂。这是一个透明面板的例子,可仿此法制作其它透明组件。有问题给我来信。8-)希望与大家分享经验。
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);
}
}
↓相关文章:
- · JAVA的声音处理方法 (转自伊氏女人)
- · js与applet的相互调用。
- · Java2的安全新特性下的Applet数字签名具体实现方法
- · 使用Java Applet访问数据库(转载)
- · 小议如何在 Applet 中显示图象
- · java applet 源程序学习1
- · - Draw a pie chart
- · J2EE学习经验和流程
- · J2EE的安全体系的应用
- · J2EE修炼之四书五经
- · 初学者如何开发出一个高质量的J2EE系统
- · J2EE Enterprise Beans(原文)
- · J2EE平台安全
- · 实战J2EE—开发购物网站(四)
- · 实战J2EE—开发购物网站(二)
- · 一个J2EE项目的最小工具集
- · J2EE电子政务门户系统
- · J2EE建议的学习路线
- · Java服务器端编程安全必读(2)
- · J2EE初学者需要理解的问题
- · J2EE架构的6个最佳实践
- · J2EE的13种核心技术(一)
- · 使用EJB3.O简化EJB开发(二)
- · 一个经典的JAVA APPLET程序(二)
- · J2EE编程起步(一)
- · j2ee-j2me tips
- · Java中的类反射机制
- · 使用sitemesh建立复合视图 - 2.装饰器 decorator
- · J2EE1.4中的Servlet部署
- · J2EE项目危机【翻译】 -避免这10项J2EE危机来确保你的企业JAVA项目成功
- · J2EE应用中与Oracle数据库的连接
- · J2ME Polish学习心得(一)----Device Optimization
- · J2EE框架标准OpenSource大战拉开序幕!
- · J2EE学习过程
- · J2EE的13种核心技术(二)
- · J2EE项目中开发团队的组建
- · J2EE开发过程中的异常处理
- · 谈谈J2SE中的序列化(三)
- · J2EE初学者需要理解的问题
- · J2EE deployment files(web.xml)
- · J2EE deployment files (ejb-jar.xml)
- · j2sdk 与 Tomcat5配置方法与注意事项
- · J2ME学习笔记(七)
- · 开发J2EE应用应遵循的几点原则
- · [J2EE]项目艰辛笔记

