jdk7透明异形窗体
来源:互联网 发布:水晶球软件 下载 编辑:程序博客网 时间:2024/06/10 02:35
在jdk6中设置透明异形窗体的方法与jdk7方法的比较
AWTUtilities.isTranslucencySupported(Translucency)
GraphicsDevice.isWindowTranslucencySupported(WindowTranslucency)
AWTUtilities.isTranslucencyCapable(GraphicsConfiguration)
GraphicsConfiguration.isTranslucencyCapable()
AWTUtilities.setWindowOpacity(Window, float)
Window.setOpacity(float)
AWTUtilities.setWindowShape(Window, Shape)
Window.setShape(Shape)
AWTUtilities.setWindowOpaque(boolean)
Window.setBackground(Color)
Passing new Color(0,0,0,alpha)
to this method, wherealpha
is less than 255, installs per-pixel translucency.jdk7判断操作系统是否支持透明窗体的设置// Determine what the default GraphicsDevice can support.GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();GraphicsDevice gd = ge.getDefaultScreenDevice();boolean isUniformTranslucencySupported = gd.isWindowTranslucencySupported(TRANSLUCENT);//是否支持全部统一透明度的窗体boolean isPerPixelTranslucencySupported = gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);//是否每部分不同透明度的窗体boolean isShapedWindowSupported = gd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT);//是否支持异性窗体System.out.println("isUniformTranslucencySupported:"+isUniformTranslucencySupported);System.out.println("isPerPixelTranslucencySupported:"+isPerPixelTranslucencySupported);System.out.println("isShapedWindowSupported:"+isShapedWindowSupported);
1.统一透明度窗体的设置
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();GraphicsDevice gd = ge.getDefaultScreenDevice();boolean isUniformTranslucencySupported = gd.isWindowTranslucencySupported(TRANSLUCENT);//是否支持全部统一透明度的窗体if(isUniformTranslucencySupported){JFrame.setDefaultLookAndFeelDecorated(true);JFrame jf=new JFrame("统一透明度");jf.setLayout(new GridBagLayout());Button bu=new Button("这是个按钮");jf.add(bu);jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);jf.setBounds(100, 60, 200, 300);jf.setOpacity(0.8f);jf.setVisible(true);}
刚开始一直弄官方例子http://download.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html,发现一直报错
Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is decoratedat java.awt.Frame.setOpacity(Unknown Source)
原来setOpacity方法说明
The TRANSLUCENT translucency must be supported by the underlying systemThe window must be undecorated (see setUndecorated(boolean) and Dialog.setUndecorated(boolean))The window must not be in full-screen mode (see GraphicsDevice.setFullScreenWindow(Window))
1.操作系统必须支持设置透明方法
2.窗体必须未修饰(无标题栏)
3.窗体必须非全屏模式
加上一句
JFrame.setDefaultLookAndFeelDecorated(true);
- jdk7透明异形窗体
- 设置背景透明的窗体,GDI+绘制异形WINFORM
- 异形窗体
- [转]用PNG透明图片和GDI+做不规则透明窗体"异形窗口"
- 用PNG透明图片和GDI+做不规则透明窗体"异形窗口"
- 用PNG透明图片和GDI+做不规则透明窗体"异形窗口"
- 用PNG透明图片和GDI+做不规则透明窗体"异形窗口"
- 部分透明,异形窗口
- delphi 无代码实现背景透明及窗体异形方法及原理
- (转)xp下实现窗体透明特效/异形窗口SetLayeredWindowAttributes函数
- 异形窗体的实现
- 异形窗体控件
- 异形窗体的实现
- 创建异形窗体
- C#实现异形窗体
- VC异形窗体
- qt 创建异形窗体
- 由图片得到异形窗体
- vb.net 计算机
- aidl 中通过RemoteCallbackList 运用到的回调机制: service回调activity的方法 .
- 自定义各类php中的时间函数
- 《Oracle编程艺术》学习笔记(6)-Oracle中的文件-参数文件
- SQL日期和时间函数
- jdk7透明异形窗体
- 到csdn来学习
- 颜色代码大全1
- VC++学习资料
- 在指定的地址空间上new
- 机器学习 1
- JAVA抽象类和接口的区别
- WINDOWS下搭建SVN源码管理库
- linux ls