ITMISS
import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; import com.sun.jna.platform.WindowUtils; /** * Transparent JFrame use JNA * * @author ruislan <a href="mailto:z17520@126.com"/> * @version 0.1.0 */ public class TransparentFrame { static class Canvas extends JPanel { protected void paintComponent(Graphics g) { if (g != null) { g.setColor(Color.black); g.fillOval(0, 0, this.getWidth(), this.getHeight()); } } } public static void main(String[] args) { System.setProperty("sun.java2d.noddraw", "true"); JFrame frame = new JFrame(); WindowUtils.setWindowAlpha(frame, 0.5f); Canvas c = new Canvas(); c.setPreferredSize(new Dimension(300, 300)); c.setSize(300, 300); JPanel panel = new JPanel(); panel.add(c); frame.add(panel, BorderLayout.CENTER); frame.setSize(600, 600); frame.setVisible(true); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } }