How to embed IE in Java
Package com. bovy. Office;
Import org. Eclipse. SWT. SWT;
Import org. Eclipse. SWT. layout. filllayout;
Import org. Eclipse. SWT. Ole. win32.ole;
Import org. Eclipse. SWT. Ole. win32.oleautomation;
Import org. Eclipse. SWT. Ole. win32.olecontrolsite;
Import org. Eclipse. SWT. Ole. win32.oleframe;
Import org. Eclipse. SWT. Ole. win32.variant;
Import org. Eclipse. SWT. Widgets. display;
Import org. Eclipse. SWT. Widgets. Menu;
Import org. Eclipse. SWT. Widgets. shell;
Public class ietest extends shell ...{
/***//***/
/***//**
* Launch the application
*
* @ Param ARGs
*/
Public static void main (string ARGs [])... {
Display display = display. getdefault ();
Ietest shell = new ietest (Display );
Shell. setmaximized (true );
Shell. setlayout (New filllayout ());
Menu bar = new menu (shell, SWT. bar );
Shell. setmenubar (bar );
Oleframe frame = new oleframe (shell, SWT. None );
Olecontrolsite clientsite = NULL;
Oleautomation browser = NULL;
Try ...{
Clientsite = new olecontrolsite (frame, SWT. None, "shell. Explorer ");
Browser = new oleautomation (clientsite );
Clientsite. doverb (OLE. oleiverb_inplaceactivate );
Shell. open ();
Int [] browserids = browser. getidsofnames (New String []... {"navigate ",
"Url "});
Variant [] address = new variant []... {new variant (
"Http://blog.csdn.net/bovy ")};
Browser. Invoke (browserids [0], address, new int []... {browserids [1]});
} Catch (exception ex )...{
System. Out. println ("failed to create ie! "+ Ex. getmessage ());
Return;
}
While (shell! = NULL &&! Shell. isdisposed ())...{
If (! Display. readanddispatch ())...{
Display. Sleep ();
}
}
Browser. Dispose ();
Display. Dispose ();
}
/***//***/
/***//**
* Create the shell
*
* @ Param display
* @ Param Style
*/
Public ietest (display )...{
Super (Display );
Createcontents ();
}
/***//***/
/***//**
* Create contents of the window
*/
Protected void createcontents ()...{
Settext ("how to embed IE in Java? Http://blog.csdn.net/bovy ");
Setmaximized (true );
//
}
@ Override
Protected void checksubclass ()...{
// Disable the check that prevents subclassing of SWT Components
}
}
Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 1557332