容器设置透明 问下,JAVA中的容器,例如JFrame,JInternalFrame,JPanel之类的可以设置透明吗?可以上个例子程序我参考下吗,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 setVisible(false)把组件隐藏了 这算是透明的一种么 import java.awt.*;import java.awt.geom.Ellipse2D;import javax.swing.*;public class TranslucentShapedWindow extends JFrame { public TranslucentShapedWindow() { super("Test translucent and oval-shaped window"); this.setLayout(new FlowLayout()); this.add(new JButton("test")); this.add(new JCheckBox("test")); this.add(new JRadioButton("test")); this.add(new JProgressBar(0, 100)); this.setSize(new Dimension(400, 300)); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Window w = new TranslucentShapedWindow(); w.setVisible(true); com.sun.awt.AWTUtilities.setWindowOpacity(w, 0.5f); com.sun.awt.AWTUtilities .setWindowShape(w, new Ellipse2D.Double(0, 0, w .getWidth(), w.getHeight())); } }); }}需要JDK1.6.10以上版本 com.sun.awt.AWTUtilities.setWindowOpacity(w, 0.5f);这个0.5f是设置透明度的 给2#注释一下 呵呵 问下com.sun.awt.AWTUtilities这又是第三方包中的类吗?有源码吗?提供下下载地址,谢谢! 知道了,晕了 要更新JDK了. 搞定了,真是太强大了.等出JDK7了,听说这个会被整合到java包下面吧.又学了点东西,谢谢啰!!! 如何利用随机数生成一个随机数组? 菜鸟求助有关绘图 java 中 DataOutputStream与BufferOutputStream应该怎么个嵌套关系?谁包裹谁? 请高人指点 google的程序大赛试题 出现一处错误 大虾帮忙看看 请高手介绍我一本JAVA好书,给100分哦 如何在jdbc中取得数据库返回的消息? 请教一个“Socket通信中的代码解决方案”. 请问文件拷贝 一个关于JTextPane的setText函数的问题 为什么不能交换参数的值
import java.awt.*;
import java.awt.geom.Ellipse2D;import javax.swing.*;public class TranslucentShapedWindow extends JFrame {
public TranslucentShapedWindow() {
super("Test translucent and oval-shaped window");
this.setLayout(new FlowLayout());
this.add(new JButton("test"));
this.add(new JCheckBox("test"));
this.add(new JRadioButton("test"));
this.add(new JProgressBar(0, 100)); this.setSize(new Dimension(400, 300));
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} public static void main(String[] args) {
JFrame.setDefaultLookAndFeelDecorated(true);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Window w = new TranslucentShapedWindow();
w.setVisible(true);
com.sun.awt.AWTUtilities.setWindowOpacity(w, 0.5f);
com.sun.awt.AWTUtilities
.setWindowShape(w, new Ellipse2D.Double(0, 0, w
.getWidth(), w.getHeight()));
}
});
}}需要JDK1.6.10以上版本
com.sun.awt.AWTUtilities这又是第三方包中的类吗?有源码吗?提供下下载地址,谢谢!
等出JDK7了,听说这个会被整合到java包下面吧.
又学了点东西,谢谢啰!!!