Java Reference
In-Depth Information
//Use operator instanceof to check subtype
//of ControllerEvent object…
if (event instanceof RealizeCompleteEvent)
{
//Attempt to create a visual component for the
//fi le type…
Component visualComponent =
player.getVisualComponent();
if (visualComponent != null)
//(Must be a video clip.)
pane.add(visualComponent,
BorderLayout.CENTER);
Component controlsComponent =
player.getControlPanelComponent();
if (controlsComponent != null)
pane.add(controlsComponent,
BorderLayout.SOUTH);
//Need to tell content pane to rearrange its
//components according to the new layout…
pane.doLayout();
}
}
}
Example output is shown in Figs. 11.3 and 11.4 .
If subsequent fi les are to be loaded, then the previous Player object must be
closed down via the following steps:
￿ retrieve the visual and control panel components via getVisualComponent and
getControlPanelComponent ;
￿
execute method remove of the container pane for each of the above components
(e.g., pane.remove(visualComponent); );
￿
execute the Player object's stop method.
(Remember to check that the Player object is non-null fi rst!)
Search WWH ::




Custom Search