Christopher has posted 9 posts at DZone. You can read more from them at their website. View Full User Profile

DJ NativeSwing - reloaded: JWebBrowser, JFlashPlayer, JVLCPlayer, JHTMLEditor.

  • submit to reddit


3. Advanced capabilities

The library takes care of most common integration issues. This covers modal dialog handling, Z-ordering, heavyweight/lightweight mix (to a certain extent), invisible native components with regards to focus handling and threading.

Here are some more screenshots, showing a lightweight/heavyweight mix, and Z-ordering capability:

Component Mix 1

Component Mix 2

The demo application that is part of the distribution shows all the features along with the source code, so check it out!


4. Project info and technical notes

Webstart demo:
Native Swing:
The DJ Project:

The 0.9.4 version has a completely new architecture. It still uses SWT under the hood, but it does not use the SWT_AWT bridge anymore.

The JWebBrowser and browser-based components require XULRunner to be installed, except on Windows when using Internet Explorer.
The JVLCPlayer requires VLC to be installed.
The JHTMLEditor uses the FCKeditor.


5. Conclusions

This project finally brings all that is needed to make Java on the desktop a reality. A web browser, a flash player, a multimedia player, and even an HTML editor. So, what next?

Yes, what next? For that one, I am waiting for your feedback. So, what do you think? What are your comments and suggestions?



Published at DZone with permission of its author, Christopher Deckers. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Christopher Deckers replied on Fri, 2008/08/22 - 10:06am in response to: puneet dixit


The Flash plugin may be installed but not on XULRunner. To fix that, you may have to run a command like:
sudo ln -s -t /usr/lib/xulrunner/ /usr/lib/mozilla/plugins/

Hope this helps!

ramesh kancherla replied on Wed, 2008/08/27 - 1:11am in response to: Christopher Deckers

Hi Christopher,

                    This is Ramesh Kancherla. I have implemented DJ WebBrowser in my  frame. 

Is there any method for disabling calander popup window maximize button.

can you please give me suggestion.


Thanks & Regards

Ramesh K

Christopher Deckers replied on Wed, 2008/08/27 - 1:31am in response to: ramesh kancherla

Hi Ramesh,

NativeSwing does not have any such specific API I think. I have some suggestions though:
- If your popup is in a separate window, then you may attach a browser listener to track when it gets open, then on the JWebBrowserWindow (which you can obtained with webBrowser.getWebBrowserWindow()) you could setResizable(false).
- If the popup is a Javascript layer, then you may try to check if some Javascript could do what you want.



Lucas de la Fuente replied on Mon, 2008/11/17 - 7:04am

Hi Christopher, I'm having problems with the flash(as3)-Java communication. The method in ActionScript is not getting response from Java. I see you have embedded some variables in the flash, but how can I communicate directly from as3 code to the commandReceived method ? All the other parts are working perfectly.


   Anyway, thanks, great job.

Christopher Deckers replied on Mon, 2008/11/17 - 7:46am in response to: Lucas de la Fuente


> The method in ActionScript is not getting response from Java

Are you calling the JS sendCommand(args) using the Flash ExternalInterface? Did you have a look at the demo application, more specifically the Function Calls example?

Don't hesitate to contact me by e-mail (chrriis (at) nextencia (dot) net) to give me a bit more details, so that I can try to help you.



Lucas de la Fuente replied on Mon, 2008/11/17 - 8:50am in response to: Christopher Deckers

Yes, I'm looking that sample again and again, but the problem is in the .as, I think.


  Im calling"thisCommand","thisArgOnly");

  Then, in Java:



flashPlayer.addFlashPlayerListener(new FlashPlayerListener() {
      public void commandReceived(String command, String[] args) { 

 //Here the string comparation: if("thisCommand".equals(command)....etc


Now I'm wondering if I'm talking only to the embedded browser and I need some other JavaScript code to make this work...


Christopher Deckers replied on Mon, 2008/11/17 - 9:15am in response to: Lucas de la Fuente

> Im calling"thisCommand","thisArgOnly");

I think there is an error in that line. It should be:"sendCommand", "thisCommand","thisArgOnly");

What this does is invoke a magic JS sendComman() function, which will internally call the FlashListener with your arguments ("thisCommand" and "thisArgOnly").

Please let me know if that was the issue.



Lucas de la Fuente replied on Mon, 2008/11/17 - 9:30am in response to: Christopher Deckers

Yes, that was the problem...Sorry for my blindness. Now all things work together.


 Many thanks !


PS: I had difficult to reach that JS information in the samples, I don't know if it's easily available, but one mention in a more visible place ( like here now ;) ) will be an unvaluable help for others.

Again, many thanks for this project.

Lucas de la Fuente replied on Mon, 2008/11/17 - 9:40am in response to: Lucas de la Fuente

OK, It was in the most visible place of the sample....:s, I had eyes only for the code....But I still think it will be more easy if it says: ""sendCommand","yourMethodName",arg1,arg2,...)

It's not clear here "sendCommand" is mandatory, and arg1 the method name etc.



Melih Öztürk replied on Sun, 2008/12/07 - 11:06am

Hi Christopher,

First of all thank you for bringing us this amazing tool, which is way better than its alikes. I am actually interested in importing some tools to DJ Native Swing and i decide to start with importing Firebug into this browser when i see the XPCOM support. So what should i do to import Firebug to DJ Native Swing web browser? I checked out some XUL samples in Mozilla project website but they are not adequate for my purpose. 

Thanks again.

Christopher Deckers replied on Sun, 2008/12/07 - 12:07pm in response to: Melih Öztürk


I don't know what is the best approach. Since FireBug is a Mozilla extension, you may be able to use it as an extension to XULRunner. Once installed, maybe some XPCOM APIs would allow you to activate it, but this is an area I don't know anything about.

In case you want to continue this discussion, feel free to e-mail me (chrriis at nextencia dot net).



suresh kumar replied on Sat, 2009/02/14 - 4:56am

Dear Chris, I use DJ Native Swing 0.9.5 for running flash player in LINUX.Its works very fine. But, sometimes the flash movie is not loading and blank white screen is displayed. This problem is getting sorted only after restarting the LINUX PC.(Note: We are setting the MOZILLA variable and path during LINUX startup). Will the new version 0.9.7 solve this issue? I am using 0.9.5. Any Suggestions?

Jan Gurda replied on Thu, 2009/02/26 - 10:29am




I have one question. I am using JWebBrowser in the JDialog, and every time I create this dialog I am also creating JWebBrowser component. Problem is  that memory of whole java process is rising. I dispose JWebBrowser during closing dialog, but memory level is not going down. After invoking 30 dialog creations memory rises about 60 Mb. Can anybody help me and give a clue what is wrong?


Thank you.





javier parra replied on Wed, 2009/07/22 - 12:42pm

Hi Christopher i just download the project and i am trying to make an aplication (web browser) but i have some problems one of them (hahahaha there are a lot of them) where can i download the .jar for interfacehandler ? or i have to make my own class for that.  well thats all for now i hope you can help me thanx in advance


Christopher Deckers replied on Wed, 2009/07/22 - 1:36pm in response to: javier parra


I am not sure what you mean by the JAR with interfacehandler: there is no such class in the project. Nevertheless, all that is needed are the NativeSwing JARs and the JARs from the libs folder (not all are needed, it depends from the feature you use, but at leat the JNA JAR files and the SWT JAR file are required).

If you need more help, do not hesitate to post your question on the help forum:


hector tino replied on Tue, 2009/09/15 - 5:29am

Hi Christopher, I used JWebBrowser, Its working fine but i need add Keylistner?.I want to exit the JWebBrowser when i pressed the ESC Key. for this i used this code:
webBrowser.getNativeComponent().addKeyListener(new java.awt.event.KeyAdapter() {
                    public void KeyPressed(java.awt.event.KeyEvent evt) {
                        int keyCode = evt.getKeyCode();
                        switch (keyCode) {
                            case KeyEvent.VK_BACK_SPACE:
                            case KeyEvent.VK_WINDOWS:
                            case KeyEvent.VK_CONTROL:
                            case KeyEvent.VK_ESCAPE:
                                muestraVisualizator();//Method for exit
but this don´t work :S how can i get a keylistener from your jWebBrowser? Thank you very much for your help, and sorry for my bad english :S Vanhack

Christopher Deckers replied on Tue, 2009/09/15 - 1:17pm in response to: hector tino


I think I found a mistake in your code which makes a difference. Instead of:
public void KeyPressed(java.awt.event.KeyEvent evt)
public void keyPressed(java.awt.event.KeyEvent evt)

And with that change, it works for me.

For future questions, I would recommend using the Help forum here.

Hope this helps,

Jagadis Natarajan replied on Thu, 2010/04/08 - 3:12am

Hi Chris,

Absolutely Love what you have done :).... It Solved me weekends of head aches ;).... Is it possible to use only Mozilla as default instead of IE? i want to do this beacuse when i load some sites which have a lot of flash content the application hangs for at elast 10 minutes before resuming operation.



Thanks a lot for this wonderful tool :)




Christopher Deckers replied on Thu, 2010/04/08 - 6:11am in response to: Jagadis Natarajan

Hi Jagadis,

> Is it possible to use only Mozilla as default instead of IE?

 Yes, provided you install or ship XULRunner (the Mozilla runtime). You need to construct the web browser using a special option. Refer to the demo application for usage.

If you have any other questions, please go to the DJ Project forum.


Jagadis Natarajan replied on Sun, 2010/04/11 - 10:41am

Thanks Chris for the prompt reply..... Will check it out... Sure to get doubts..... Will post here if i have them :)


Thanks again.... highly appreciate your work!!!!! Rock on \m/ :) 

Jagadis Natarajan replied on Sun, 2010/04/11 - 7:01pm

One more question,

The Application seems to hang on for about 10 minutes whenever a site with lots of flash content loads (Unable to close, unable to navigate away from the site.. have to sit for 10 mins) and thn it responds. 


Is this a known issue or is it just occuring to me.... if its just me then i'll take a better look at my code 




Christopher Deckers replied on Mon, 2010/04/12 - 5:25am in response to: Jagadis Natarajan

Hi Jagadis,

I have never heard of such issue. If you have an actual web site I could test please let me know.

But please, do not comment here. Add a post in the forum. That way, other users may be able to help and your problem would help other users.


Umme Habiba replied on Wed, 2011/07/13 - 12:40am

Hi Chris,

I used JWebBrowser, Its working fine but I want to handle JWebBrowser's  "navigate(uri)" method with its return true or false value. But its always returning false whether the page load succesfully or not.

        final JWebBrowser webBrowser = new JWebBrowser();
        boolean canDisplay = webBrowser.navigate(uri);


//             load a new default page.


Ican't make it working. Can you please help with this problem.

I'm using windowsXP, and java swing here.

Christopher Deckers replied on Wed, 2011/07/13 - 6:11am in response to: Umme Habiba

Hi Umme,

The result indicate whether the browser accepted the request. Not whether the page was succefully loaded. In any case, detecting whether a page loaded probably does not mean much because of possible HTTP redirects, dedicated 404 pages and so on.

The closest you can do is add a web browser listener and respond to some events (locationChangeCanceled).

By the way, next time (or if you want to respond), create a topic in the help forum.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.