Java如何设置图片的透明度

	@Override
	public void paint(Graphics g){
		try {
			Image bgimage = ImageIO.read(new File("src/image/bgimage.png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
	    Graphics2D g2d = (Graphics2D) g; 
	    g2d.setComposite(ac);
	    g2d.drawImage(bgimage, x, y, width, height, this);
	}

你可能感兴趣的:(Java)