Tela Transparente

1 resposta
fasc90

Olá Desenvolvedores.

por que não há como mudar a opacidade em uma janela decorada ?????? :cry: :cry: :cry:

[url]http://javafree.uol.com.br/topic-882662-Janelas-transparentes.html[/url]

gostaria de saber se há como deixar a tela transparente sem utilizar isso:

JFrame.setDefaultLookAndFeelDecorated(true);

pra que a borda da tela fique com uma aparência melhor, o único modo que encontrei pra fazer isso é usando o setUndecorated(true).

também não estou conseguindo usar este comando:

com.sun.awt.AWTUtilities.setWindowOpacity

minha versão é o jdk 7.

Valeu gente !

import static java.awt.GraphicsDevice.WindowTranslucency.TRANSLUCENT;

import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class test extends JFrame{
	public test() {
        super("Test");
        setLayout(new GridBagLayout());
        setSize(300,200);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        add(new JButton("Button"));
    }

	public static void main(String[] args) {
        
		GraphicsEnvironment ge = 
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        
        if (!gd.isWindowTranslucencySupported(TRANSLUCENT)) {
            System.err.println(
                "Translucency is not supported");
                System.exit(0);
        }
        
        JFrame.setDefaultLookAndFeelDecorated(true);
        
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                test ts = new test();
                ts.setOpacity(0.55f);
                ts.setVisible(true);
            }
        });
    }
}

1 Resposta

InicianteJavaHenriqu

:shock: eu nem sabia que tinha mudado a forma de deixar transparente e mudar o formato das janelas no Java SE 7, no 6 era bem mais trabalhoso.

P.S.: infelizmente não pude ajudar, mas obrigado por ter aberto este tópico.

:thumbup:

Criado 29 de julho de 2012
Ultima resposta 30 de jul. de 2012
Respostas 1
Participantes 2