Voy a postear el codigo ke estoy usando haber si pueden encontrar el error:
Clase Video.java
Código JAVA:
Ver originalimport java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
public class video
extends javax.
swing.
JFrame {
public video() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1
= new javax.
swing.
JPanel(); jButton1
= new javax.
swing.
JButton();
jPanel1.
setBackground(new java.
awt.
Color(51,
51,
255));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.
addGap(0,
330,
Short.
MAX_VALUE) );
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.
addGap(0,
223,
Short.
MAX_VALUE) );
jButton1.setText("Ver");
public void actionPerformed
(java.
awt.
event.
ActionEvent evt
) { jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.
addContainerGap(38,
Short.
MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.
addContainerGap(177,
Short.
MAX_VALUE) .addComponent(jButton1)
.addGap(172, 172, 172))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton1)
.
addContainerGap(25,
Short.
MAX_VALUE)) );
pack();
}// </editor-fold>
private void jButton1ActionPerformed
(java.
awt.
event.
ActionEvent evt
) { // TODO add your handling code here:
ponervideo();
}
public void ponervideo() {
int result = fileChooser.showOpenDialog(null);
if (result
== JFileChooser.
APPROVE_OPTION) // user chose a file {
try {
// get the file as URL
mediaURL = fileChooser.getSelectedFile().toURL();
} // end try
System.
err.
println("Could not create URL for the file"); } // end catch
if (mediaURL != null) {
MediaPanel mediaPanel = new MediaPanel(mediaURL);
jPanel1.add(mediaPanel);
this.add(panel);
this.setVisible(true);
}
}
}
public static void main
(String args
[]) {
public void run() {
new video().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.
swing.
JButton jButton1
; private javax.
swing.
JPanel jPanel1
; // End of variables declaration
}