Fala galera, eu andei dando uma lida aqui no fórum e no site da sun, porém não consegui resolver meu problema, talvez seja a forma com a qual estou fazendo, pode estar errado.
Eu queria deixar um JFrame, JWindow ou ate um JPanel transparente, para que eu possa criar uma tela Splash, em que o fundo seja uma imagem que eu criar, assim ela poderia ser do formato que eu escolhesse.
Vou deixar um código abaixo.
package proEvolution;
import de.javasoft.plaf.synthetica.SyntheticaPlainLookAndFeel;
import javax.swing.*;
import java.awt.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import static java.lang.Thread.sleep;
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
//public class TelaSplash extends JWindow
public class TelaSplash //extends JFrame
{
private JProgressBar progressBar = new JProgressBar();
//private JPanel painel = (JPanel)getContentPane();
private JLabel carregando = new JLabel();
private ImageIcon imagem = new ImageIcon();
private JFrame frame = new JFrame();
public TelaSplash()
{
criarTelaSplash();
frame.setSize(500, 300);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
frame.setOpacity(0.5f);
}
public void criarTelaSplash()
{
frame.setUndecorated(true); // tira decoração (barra de titulo e etc).
//painel.setBackground(new Color (113, 192, 255));
progressBar.setMinimum(0);
progressBar.setMaximum(100);
progressBar.setStringPainted(true);// mostra a %
progressBar.setBackground(new Color(113, 192, 255));
progressBar.setForeground(new Color(48, 97, 171));
frame.add(progressBar);
//progressBar.setPreferredSize(new Dimension(500, 15));
//painel.add(progressBar, BorderLayout.AFTER_LAST_LINE);
frame.add(progressBar, BorderLayout.AFTER_LAST_LINE);
//progressBar.setBounds(0, 269, 500, 12);
JLabel nome = new JLabel("<html> <font color=#3061AB> Copyright 2016, <b> XXXXX </b> </font> </html>", JLabel.CENTER);
nome.setFont(new Font("SansSerif", Font.BOLD, 12));
// painel.add(nome, BorderLayout. NORTH);
frame.add(nome, BorderLayout. NORTH);
JLabel label = new JLabel (new ImageIcon(getClass().getResource("/imagens/teste02.png")));
frame.add(label, BorderLayout.CENTER);
carregando.setHorizontalAlignment(SwingConstants.CENTER);
//painel.add(carregando,BorderLayout.SOUTH);
frame.add(carregando,BorderLayout.SOUTH);
Thread t = new Thread()
{
public void run()
{
int i = 0;
//while (i <= 100)
for (i = 0; i <101; i++)
{
progressBar.setValue(i);
try
{
sleep(90);
if (progressBar.getValue() <=30)
{
carregando.setText("Carregando banco de dados..");
}
else if (progressBar.getValue() <=55)
{
carregando.setText("Iniciando painéis..");
}
else if (progressBar.getValue() <=85)
{
carregando.setText("Criando módulos..");
}
else
{
carregando.setText("Carregando sistema..");
}
}
catch (InterruptedException ex)
{
Logger.getLogger(TelaSplash.class.getName()).log(Level.SEVERE, null, ex);
}
}
if(i == 100)
{
System.exit(0);
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
telaPrincipal();
}
};
t.start();
}
public void telaPrincipal()
{
try
{
UIManager.setLookAndFeel(new SyntheticaPlainLookAndFeel());
}
catch (Exception e)
{
e.printStackTrace();
}
//TelaPrincipal pricipal = new TelaPrincipal();
}
}