找了找好像只有 fillRect...fillPolygon...之类的。。没发现透明

解决方案 »

  1.   

    透明的不是图形,是Composite。
      

  2.   

    最新的jdk-6u10版本已经在进行beta测试,对于swing来说,在此版本中增加了两个重要的功能:透明窗体和不规则窗体。这两个功能使得swing也可以做出vista下的玻璃效果来了, 
    jdk-6u10还没有正式发布,可以在http://download.java.net/jdk6/binaries/进行下载
    publicclassTranslucentWindowextendsJFrame{  
      publicTranslucentWindow(){  
        super("透明窗体");  
        this.setLayout(newFlowLayout());  
        this.add(newJButton("按钮"));  
        this.add(newJCheckBox("复选按钮"));  
        this.add(newJRadioButton("单选按钮"));  
        this.add(newJProgressBar(20,100));  
        this.setSize(newDimension(400,300));  
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
      }  
      publicstaticvoidmain(String[]args){  
        JFrame.setDefaultLookAndFeelDecorated(true);  
        SwingUtilities.invokeLater(newRunnable(){  
          publicvoidrun(){  
            Windoww=newTranslucentWindow();  
            w.setVisible(true);  
            com.sun.awt.AWTUtilities.setWindowOpacity(w,0.6f);  
          }  
        });  
      }  
    }
    publicclassTranslucentWindowextendsJFrame{  
      publicTranslucentWindow(){  
        super("透明窗体");  
        this.setLayout(newFlowLayout());  
        this.add(newJButton("按钮"));  
        this.add(newJCheckBox("复选按钮"));  
        this.add(newJRadioButton("单选按钮"));  
        this.add(newJProgressBar(20,100));  
        this.setSize(newDimension(400,300));  
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
      }  
      publicstaticvoidmain(String[]args){  
        JFrame.setDefaultLookAndFeelDecorated(true);  
        SwingUtilities.invokeLater(newRunnable(){  
          publicvoidrun(){  
            Windoww=newTranslucentWindow();  
            w.setVisible(true);  
            com.sun.awt.AWTUtilities.setWindowOpacity(w,0.6f);  
          }  
        });  
      }  
    }来自http://wenwen.soso.com/z/q131333431.htm
      

  3.   

    drawRect/drawPolygon 绘制的图形只有边,算透明吗?
    使用带alpha分量的Color fill算透明不?