现在的位置: 首页 > 综合 > 正文

设置图片透明度

2019年06月14日 ⁄ 综合 ⁄ 共 404字 ⁄ 字号 评论关闭


  1. @Override
      


  2. public
     void paint(Graphics g){  

  3.     try  

  4.         Image bgimage ImageIO.read(new File("src/image/bgimage.png"));  

  5.     catch (IOException e)  

  6.         e.printStackTrace();  

  7.      

  8.     AlphaComposite ac AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);  

  9.     Graphics2D g2d (Graphics2D) g;   

  10.     g2d.setComposite(ac);  

  11.     g2d.drawImage(bgimage, x, y, width, height, this);  

  12. }  

抱歉!评论已关闭.