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 simple Javascript to send some commands with arguments to the application:
function sendCommand(command) {
var s = 'command://' + encodeURIComponent(command);
for(var i=1; i<arguments.length; s+='&'+encodeURIComponent(arguments[i++]));
window.location = s;
}Access and modify the cookies set by the various browser instances.
Load web pages from the classpath with the help of the embedded simple web server.
Toggle edition mode of a web page by accessing the Mozilla interfaces using XPCOM.
Modify the browser's download manager using Mozilla XPCOM.
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.
Graphically edit some HTML, get and set the HTML content.
Modify default behaviors with custom configuration script.
Use the TinyMCE editor implementation instead of the default FCKeditor.
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.
Constrain the visibility to superimpose Swing and native components.
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.
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.
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().
Get the file type associations, and use them to launch files.