欢迎光临
我们一直在努力

如何制作透明组件。-JSP教程,Application/Applet

建站超值云服务器,限时71元/月

懒得写说明了,大家应该能看懂。这是一个透明面板的例子,可仿此法制作其它透明组件。有问题给我来信。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 cant 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);
}
}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何制作透明组件。-JSP教程,Application/Applet
分享到: 更多 (0)