Java Reference
In-Depth Information
getFile();
createPlayer();
}
catch(FileNotFoundException fnfEx)
{
JOptionPane.showMessageDialog(this,
"File not found!", "Invalid fi le name",
JOptionPane.ERROR_MESSAGE);
}
//Step 4…
catch (Exception ex)
{
JOptionPane.showMessageDialog(this,
"Unable to load fi le!", "Invalid fi le type",
JOptionPane.ERROR_MESSAGE );
}
}
private void getFile() throws FileNotFoundException
{
//Step 1…
fi le = new File(fi leName.getText());
//Step 2…
if (!fi le.exists())
throw new FileNotFoundException();
}
private void createPlayer() throws Exception
{
//Step 3…
player = Manager.createPlayer(fi le.toURL());
//Note use of File class's toURL method to
//convert a File object into a URL object.
//Step 5…
player.addControllerListener(this);
//Step 7…
player.start();
fi leName.setEnabled(false);
}
//Step 6…
public void controllerUpdate(ControllerEvent event)
{
Container pane = getContentPane();
//Needed for adding JMF GUI components to the
//application (as explained before example).
Search WWH ::




Custom Search