How to embed IE in Java

Source: Internet
Author: User
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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.