ws18921818762
代码大萝卜
2017-04-11 07:47

java swin 窗体透明(我想做不规则窗体哒)

  • java
  • string

怎么无法实现jframe的窗体透明呢?代码见下面,谢谢各位大大:

 import com.sun.awt.AWTUtilities;  
    import java.awt.Color;  
    import java.awt.Graphics;  
    import javax.swing.JFrame;  
    import javax.swing.JPanel;  

    public class Test {  

        public static void main(String[] args) {  
            JFrame frame = new JFrame();  
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
            frame.setUndecorated(true);  
            frame.setBounds(500, 500, 300, 300);  
            AWTUtilities.setWindowOpaque(frame, false);  


            JPanel pane = new JPanel() {  

                @Override  
                public void paint(Graphics g) {  
                    super.paint(g);  

                    g.setColor(Color.red);  
                    g.fill3DRect(10, 10, 100, 100, true);  
                }  
            };  

            frame.setContentPane(pane);  

            frame.setVisible(true);  
        }  
    }  

运行结果:
图片说明

窗体周围又一圈灰色的东东怎么去掉哇~

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答