Pessoal preciso de uma ajuda…Preciso criar um media player em java para executar videos e colocar algumas imagens sobre esse video como se fosse marca d"agua.Como se fosse uma moldura e os videos entrasse por de baixo…entao pensei o seguinte…Criar uma janela onde vai passar o video…isso ja funciona no codigo abaixo…e queria colocar uma janela sobre esta com o container transparente e as imagens…Isso funciona…ou colocar uma janela sobre a outra…sendo uma transparente…Segue abaixo o codigo…
public class MediaPanel extends JPanel {
public MediaPanel(URL mediaURL){
setLayout(new BorderLayout());
Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
try{
Player mediaPlayer = Manager.createRealizedPlayer(mediaURL);
Component video = mediaPlayer.getVisualComponent();
Component controls = mediaPlayer.getControlPanelComponent();
if(video != null)
add(video, BorderLayout.CENTER);
if(controls != null)
add(controls, BorderLayout.SOUTH);
mediaPlayer.start();
}catch(NoPlayerException noPlaterException){
System.err.println("Nao existe media player");
}catch(CannotRealizeException cannotRealizeException){
System.err.println("Nao realizou media player");
}catch(IOException ioException){
System.err.println("Error Reading");
}
}
}
public class MediaTest extends JFrame{
public static void main(String args[]) throws IOException{
JFileChooser fileChooser = new JFileChooser();
int result = fileChooser.showOpenDialog(null);
if(result == JFileChooser.APPROVE_OPTION){
URL mediaURL = null;
try{
mediaURL = fileChooser.getSelectedFile().toURL();
System.out.println(mediaURL);
}catch(MalformedURLException malformedURLException){
System.err.println("not create url file");
}
if(mediaURL != null){
JFrame mediaTest = new JFrame("WIT Pendrive");
mediaTest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MediaPanel mediaPanel = new MediaPanel(mediaURL);
mediaTest.add(mediaPanel);
mediaTest.setVisible(true);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
mediaTest.setBounds(0,0,screenSize.width, screenSize.height);
}
JFrame frame = new JFrame("Carregar Imagem");
Container container = frame.getContentPane();
JPanel panel = new JPanel();
panel.setOpaque(true);
panel.setLayout(null);
ImageIcon img = new ImageIcon("res/globo.jpg");
JLabel label = new JLabel(img);
label.setVisible(true);
panel.add(label);
label.setBounds(191, 63, 50, 50);
label.setVisible(true);
label.setOpaque(true);
container.add(panel, BorderLayout.CENTER);
panel.setPreferredSize(new java.awt.Dimension(500, 404));
panel.setVisible(true);
panel.setEnabled(true);
frame.pack();
frame.setVisible(true);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setBounds(0,0,screenSize.width, screenSize.height);
}
}
}