2

だから私は自分の問題を試してみることができますが、あなたと私のために、私が達成したいことをあなたに伝えるために、フォトショップで簡単な画像を作成しました:

ここに画像の説明を入力してください

私はAWTUtilitiesで不透明なものを使って作業しようとしましたが、うまくいかないようです。どうすればこれを達成できるかわかりますか?

ウィンドウをドラッグアンドドロップできるように、ネイティブウィンドウの境界線が必要です。また、サイズ変更機能も必要です。

前もって感謝します

4

1 に答える 1

1

透明/半透明については、 http : //docs.oracle.com/javase/tutorial/uiswing/misc/trans_shape_windows.htmlJFrame を参照してください。これは、Javaでの半透明のWindowsについて説明しています。

を呼び出す必要があります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);
            }
        });
    }
}
于 2012-08-21T18:32:48.263 に答える