Here are all the code snippets from the demo application: click on their name to see the corresponding source code.
To see them running, download the DJ Native Swing distribution and launch the demo application (you can also see the source code of the snippets with syntax highlighting in the demo).
This is a simple example that shows the basic configuration of an embedded web browser component.
Set any HTML content to the web browser.
Execute some Javascript code in the current web browser page.
Control the navigation happening in the web browser from the Java application. This allows to block certain links and/or the creation of new windows, or to open links and/or new windows elsewhere.
Use static links or the Javascript sendNSCommand(name, arg1, arg2, ...) function to send commands to the Java application.
Access and modify the cookies set by the various browser instances.
Define HTTP headers and/or POST data to send along with the HTTP navigation request.
Load web pages from the classpath with the help of the embedded simple web server.
Dispose a web browser giving the current page the opportunity to ask for confirmation.
Register a Java function that can be invoked from Javascript.
Toggle edition mode of a web page by accessing the Mozilla interfaces using XPCOM.
Modify the browser's download manager using Mozilla XPCOM.
Modify the browser's decorator, to add our own menus and buttons.
Capture the image of the page, including the portions that are outside of the viewport of the main document.
Display a Flash application.
Control the flow of a Flash animation, and get/set global variables.
Invoke functions, with or without waiting for a result, and listen to Flash commands.
Load a movie/sound file to an embedded VLC player.
Load a file to VLC player, passing certain options (start time to 30, no audio and no title) using the playlist.
Graphically edit some HTML, get and set the HTML content, using the FCKEditor implementation.
Graphically edit some HTML, get and set the HTML content, using the CKEditor implementation.
Graphically edit some HTML, get and set the HTML content, using the TinyMCE implementation.
Track whether the editor was modified since the last time its content was set.
Display some content with syntax highlighting from one of the available languages (C++, C#, css, Delphi, Java, JS, PHP, Python, Ruby, SQL, VB, XML, HTML).
Load a movie/sound file to an embedded multimedia player.
Use a file dialog or a directory dialog, and customize them to your needs.
Constrain the visibility to superimpose Swing and native components. Note that Mac only supports shapes resolving to a single rectangle.
Defer destruction until finalization to add/remove the same component. It is not destroyed when removed but on disposeNativePeer() or garbage collection.
Use a proxied component hierarchy for the native components to allow re-parenting and change of component Z-order. Note that Mac only supports shapes resolving to a single rectangle.
Create a thumbnail by painting a native component to an image.
Simulate alpha blending of a Swing component over a native component. This works rather well over static content. Note that Mac only supports shapes resolving to a single rectangle.
Present the life cycle of a component and when method calls happen. Also highlight how runInSequence(Runnable) can be useful, and for special needs how to use initializeNativePeer().
Attach a listener for key and mouse events, and go as far as replacing the web browser popup menu with a Swing one.
Get the file type associations, and use them to launch files.