在Java1.5中如何设置 jwindow透明,查了下其他有说用AWTUtilities.setWindowOpacity(frame, 0.5f);但这个是在JDK1.6中的,是否可以把1.6的这个包 import com.sun.awt.AWTUtilities 导入到1.5??还是有其他的方法??请给点实例哈。。谢谢;
解决方案 »
- java 聊天记录
- Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes这是什么错误?
- 编译声称的class文件或者是jar文件是否可以与其他语言交互的?
- 两个简单问题,解决马上给分!
- 急,正则表达式如何实现下列匹配?
- 总是抛出空指针异常
- 如何让在一个已经运行的jvm中运行另外的class.
- 请帮我看看这个变量(属性)属于什么类型,谢谢!
- 各位高手帮帮小弟!!一个细节问题!!
- 菜鸟的多线程简单问题~~~
- RCP工程中如何动态的控制工具栏的隐藏和显示
- Scanner的疑惑
/** the screenshot that is used to draw transparency */
protected BufferedImage screenShot = null;
/** the robot instance that captures screen shots */
protected Robot robot;
/** the rectangle that defines the screen dimensions */
protected Rectangle rect;
public MyWindow(JFrame frame){
super(frame);
try {
robot = new Robot();
} catch (AWTException e) {
e.printStackTrace();
}
}
/* (non-Javadoc)
* @see java.awt.Component#paint(java.awt.Graphics)
*/
public void paint(Graphics g) {
if (robot != null){
Graphics2D g2D = (Graphics2D)g;
g2D.drawImage(screenShot,null,0,0);
g2D.setColor(Color.RED);
g2D.drawLine(rect.x,rect.y,rect.x + rect.width,rect.y + rect.height);
}
}
/**
* Sets the frame visibility and also, if transparency is turned on, captures
* the screen shot.
* @param isVisible the visibility of the frame
*/
public void setVisible(boolean isVisible)
{
if (isVisible){
captureScreenShot();
}
super.setVisible(isVisible);
}
private void captureScreenShot()
{
try
{
robot = new Robot();
rect = getBounds();
screenShot = robot.createScreenCapture(rect);
}
catch (java.awt.AWTException ex) {}
}
}
使用 WindowUtils的setWindowAlpha方法