-1

I want to show JLabel but want to hide JFrame border and other lower level containers like JPanel. It just JLabel displayed on the screen.

I tried window transparency but following piece of code hides everything if trying to work with window opacity. On decreasing windowOpacity , even JLabel becomes blurred. I tried with JPanel as well but couldn't get exact output. I want this behaviour in jdk1.6 only I want the JLabel content to be visible properly without any opacity impact but backbround must be purely transparent.

     public class TEST {

    public static void main(String[] args) {

        JFrame frame = new JFrame("Sanjaal Corps - Windows On Top Demo!");
        frame.setSize(400, 100);
        frame.setLocation(100, 150);        
        com.sun.awt.AWTUtilities.setWindowOpacity(frame,0.4f);
        frame.setUndecorated(true);
        frame.add(new JLabel("TESTING"));       
        frame.setAlwaysOnTop(true);
        frame.setVisible(true);

    }

}

I tried with solution provided http://www.dreamincode.net/forums/topic/140041-make-a-jpanel-transparent-to-see-the-desktop-behind/

But the problem here is if we minimize or maximize the window , then a constant color being set, So found its not the best solution or may say the Perfect one.

4

2 に答える 2

3

テキスト/アイコンであるラベル (他には何もない)の前景を表示したいと仮定すると、フレームの不透明度を false に設定します。

com.sun.awt.AWTUtilities.setWindowOpaque(frame, false);

com.sun.** クラスの使用に対する通常の注意事項。 残念ながら、これは java7 より前の透明なウィンドウにアクセスする唯一の方法です。

于 2013-09-01T11:24:41.153 に答える