The biggest advantage of SWT is that Windows has a window style, which combines SWT with JMF, Windows external frame, and Java player. What do you think of me?
If you want to run my code, you must install jmf2.1.1e and import the swt jar file (remember to put the swt-win32-2135.dll in the execution path)
ImportJava. AWT. borderlayout;
ImportJava. AWT. component;
ImportJava. AWT. Panel;
ImportJava. Io. ioexception;
ImportJava.net. malformedurlexception;
ImportJava.net. url;
ImportJavax. Media. configurecompleteevent;
ImportJavax. Media. controllerevent;
ImportJavax. Media. controllerlistener;
ImportJavax. Media. endofmediaevent;
ImportJavax. Media. Manager;
ImportJavax. Media. noplayerexception;
ImportJavax. Media. player;
ImportJavax. Media. realizecompleteevent;
ImportOrg. Eclipse. jface. Window. window;
ImportOrg. Eclipse. SWT. SWT;
ImportOrg. Eclipse. SWT. Internal. AWT. win32.swt _ AWT;
ImportOrg. Eclipse. SWT. Widgets. display;
ImportOrg. Eclipse. SWT. Widgets. shell;
/**
* @ Author
* <A href = "mailto: jdcyang@yahoo.com.cn"> Liu Yang </a>
* 19:34:38
*/
Public ClassSwtplayerImplementsControllerlistener {
Public Static VoidMain (string [] ARGs ){
Swtplayer sp =NewSwtplayer ();
Sp. Play ();
}
Private BooleanConfigured =False;
Private BooleanRealized =False;
Player player;
Panel panel;
Public VoidPlay (){
Display display =NewDisplay ();
Shell shell =NewShell (display, SWT. MAX );
Shell. setSize (320,240 );
Shell. setText ("Hello SWT ");
Panel = SWT_AWT.New_ Panel (shell );
URL url = null;
Try{
Url =NewURL ("file:/D:/video/jboss. mpeg ");
}Catch(MalformedURLException e ){
E. printStackTrace ();
}
Try{
Player = Manager. createPlayer (url );
}Catch(NoPlayerException e1 ){
E1.printStackTrace ();
}Catch(IOException e1 ){
E1.printStackTrace ();
}
Player. addControllerListener (This);
Player. realize ();
While(! Realized ){
Try{
Thread. sleep (100L );;
}Catch(InterruptedException e ){
// Ignore
}
}
Panel. setLayout (NewBorderLayout ());
Panel. add (player. getVisualComponent (), BorderLayout. CENTER );
Component cpc = player. getControlPanelComponent ();
If(Cpc! = Null ){
Panel. Add (CPC, borderlayout. South );
}Else{
}
Player. Start ();
Shell. open ();
Window win;
While(! Shell. isdisposed ()){
If(! Display. readAndDispatch () display. sleep ();
}
Display. dispose ();
}
/* (Non-Javadoc)
* @ See javax. media. ControllerListener # controllerUpdate (javax. media. ControllerEvent)
*/
Public VoidControllerUpdate (ControllerEvent evt ){
If(EvtInstanceofRealizeCompleteEvent ){
Realized =True;
}ElseIf(EvtInstanceofConfigureCompleteEvent ){
Configured =True;
}Else If(EvtInstanceofEndOfMediaEvent ){
}Else{
}
}
}