Java - Imagen con transparencia en un Jframe

 
Vista:

Imagen con transparencia en un Jframe

Publicado por Sniper (1 intervención) el 30/05/2012 06:57:13
Hola! Veran quisiera que me aconsejaran con lo siguiente:

Estoy haciendo en NetBeans un JFrame que contenga un JLabel con una imagen, esta imagen es un gif con transparencia, lo que quiero lograr es hacer un ejecutable que mantenga siempre visible ese gif sobre todas mis ventanas.

Ya logre eso, pero el gif pierde su transparencia y me sale con fondo gris caracteristico de los JFrame.

Mi duda es, ahi forma de que ese fondo gris desaparesca y me muestre solo el gif con su trasnparencia?

Al JFrame le aplique setUndecorated para que no tenga bordes. Intente aplicar el codigo para opacarlo y darle transparencia, pero no me funciona. El codigo actual esta asi:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
public class Main extends javax.swing.JFrame {
 
    /** Creates new form Main */
    public Main() {
        super();
        initialize();
        //setUndecorated(true);
        initComponents();
        //WindowsUtil.makeWindowsOpacity(this, .7f);
        WindowsUtil.makeWindowsShape(this, panelNice1.getShape());
        new WindowDragger(this, panelNice1);
        titleBar1.addCloseAction(new ActionListener() {
 
            public void actionPerformed(ActionEvent ae) {
                close();
            }
        });
        setLocationRelativeTo(null);
    }
 
    private void close() {
        System.exit(0);
    }
 
initComponents...
 
    public static void main(String args[]) {
        SwingUtilities.invokeLater(new Runnable() {
 
            public void run() {
                try {
                    UIManager.setLookAndFeel(
                            UIManager.getSystemLookAndFeelClassName());
                } catch (Exception e) {
                }
                //new Main().setVisible(true);
                Main thisClass = new Main();
                thisClass.setAlwaysOnTop(true);
                thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                thisClass.setVisible(true);
                try {
                    @SuppressWarnings("rawtypes")
                    Class clazz = Class.forName("com.sun.awt.AWTUtilities");
                    @SuppressWarnings("unchecked")
                    Method method = clazz.getMethod("setWindowOpaque", java.awt.Window.class, Boolean.TYPE);
                    method.invoke(clazz, thisClass, false);
                } catch (Exception e) {
                }
            }
        });
    }
 
    private void initialize() {
        this.setSize(601, 548);
        this.setUndecorated(true);
        this.setResizable(false);
        this.setLocationRelativeTo(null);
        this.setTitle("Pokémon Special Plus+");
    }
 
    // Variables declaration - do not modify
    private javax.swing.JLabel jLabel1;
    private org.edisoncor.gui.panel.PanelNice panelNice1;
    private org.edisoncor.gui.varios.TitleBar titleBar1;
    // End of variables declaration
}

Algun consejo para que mi JFrame tenga fondo transparente sin afectar al gif?

Gracias por leer
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Imagen con transparencia en un Jframe

Publicado por kronycksoft (1 intervención) el 28/04/2014 23:53:29
SetOpacity(0.5f);
Elige un numero decimal dle 0.1 al 0.9 para que te funcione y la f despues dle numero le das el aparametro para decirle que es float saludos :D
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Imagen con transparencia en un Jframe

Publicado por Aprendiendo Java (1 intervención) el 18/08/2017 00:54:36
.......
public Ejemplo ( ) {
setLayout(null);
setUndecorated(true);
setLocationRelativeTo(null);
Ejemplo.this.getRootPane().setOpaque(false);
Ejemplo.this.getContentPane().setBackground(new Color (0,0,0,0));
Ejemplo.this.setBackground(new Color (0,0,0,0));
........
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar