Java jframe中的透明背景,但带有窗口边框等

Java jframe中的透明背景,但带有窗口边框等,java,transparency,awtutilities,Java,Transparency,Awtutilities,所以我可以试着问我的问题,但为了你和我的缘故,我在photoshop中创建了一个简单的图像,试图告诉你我想要实现的目标: 我试着用一些不透明的东西,但似乎不起作用。你们知道我怎样才能做到吗 我确实需要本机窗口边框,以便可以拖放窗口,还需要调整大小功能 提前感谢您提供的透明/透明JFrame请参见此处:它解释了Java中的半透明窗口 您需要调用setOpacity() 这里还有一个小例子: import java.awt.*; import javax.swing.*; import stati

所以我可以试着问我的问题,但为了你和我的缘故,我在photoshop中创建了一个简单的图像,试图告诉你我想要实现的目标:

我试着用一些不透明的东西,但似乎不起作用。你们知道我怎样才能做到吗

我确实需要本机窗口边框,以便可以拖放窗口,还需要调整大小功能


提前感谢您提供的透明/透明
JFrame
请参见此处:它解释了Java中的半透明窗口

您需要调用
setOpacity()

这里还有一个小例子:

import java.awt.*;
import javax.swing.*;
import static java.awt.GraphicsDevice.WindowTranslucency.*;

public class TranslucentWindowDemo extends JFrame {

    public TranslucentWindowDemo() {
        super("TranslucentWindow");
        setLayout(new GridBagLayout());

        setSize(300, 200);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Add a sample button.
        add(new JButton("I am a Button"));
    }

    public static void main(String[] args) {
        // Determine if the GraphicsDevice supports translucency.
        GraphicsEnvironment ge =
                GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();

        //If translucent windows aren't supported, exit.
        if (!gd.isWindowTranslucencySupported(TRANSLUCENT)) {
            System.err.println(
                    "Translucency is not supported");
            System.exit(0);
        }

        JFrame.setDefaultLookAndFeelDecorated(true);

        // Create the GUI on the event-dispatching thread
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                TranslucentWindowDemo tw = new TranslucentWindowDemo();

                // Set the window to 55% opaque (45% translucent).
                tw.setOpacity(0.55f);

                // Display the window.
                tw.setVisible(true);
            }
        });
    }
}


你到底想要达到什么样的效果,而这张图片却没有显示出来?它对我来说是透明的,这是我想要实现的,但它是经过Photoshop处理的;)