如何设置JWINDOW 透明?? 在Java1.5中如何设置 jwindow透明,查了下其他有说用AWTUtilities.setWindowOpacity(frame, 0.5f);但这个是在JDK1.6中的,是否可以把1.6的这个包 import com.sun.awt.AWTUtilities 导入到1.5??还是有其他的方法??请给点实例哈。。谢谢; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你把你的jre环境设置成1.6的不行么 不然你只能重写jwindow了:class MyWindow extends JWindow{ /** 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) {} }} 使用 jna。下载jna.jar + platform.jar使用 WindowUtils的setWindowAlpha方法 sin,con,tan 运行后的结果不太正确,望指点 如何在多个线程执行完后再执行某个方法 java read问题 论回帖与结帖 关于JAVA与数据库连查询的问题!!!!! 能运行就给分 如何利用JTable做一个家庭收入的界面系统 一个初级问题 用基类类型获得一个对象后,如何获取对象的实际属于哪个子类型? JDK在XP下的配置???? 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方法