Mixing Swing and Native Components
Join the DZone community and get the full member experience.Join For Free
Bringing Together Various Components
There are situations in which it may be to the benefit of a programmer or other computer user to look at bringing together native components of a system with swing components. These are components that they have either created on their own accord or components that they have brought over from another service.
Either way, combining the native components that already exist in a system with swing components is a great way to achieve some surprising results. You might want to think about giving this a try if you are thinking about how you can bring your talents up to date for use in the world as it is today.
DJ Native Swing is a nice solution to embed native components (Web Browser, Flash Player, etc.).
There was still a general issue that this library did not resolve though: the possibility to mix heavyweight and lightweight components with lightweight components on top, to change their Z-order or re-parent them.
Fortunately, The release 0.9.3 offers interesting advances in this area.
Using these features is as simple as changing some options before instantiating native components, in order to extend their behavior.
You can try all the features (including the new options) with the Webstart Demo: http://djproject.sourceforge.net/ns/DJNativeSwingDemo.jnlp
The Webstart demo is configured to work on Windows. It also works on Linux (GTK, x86/i386) where XULRunner is installed. Note that this demo is part of the release package.
Run Tests on Every Component
It is a good idea to run a demo of any components that you think you might want to put together. The reason for this is that you need to make sure those components will work for you as you anticipate that they will. This is far from a guarantee, and that is why you are called upon to pay careful attention to the things that you are running through these systems.
It is entirely possible that you might find some errors that you made along the way when you are checking out the system to see where you went wrong.
There is nothing bad about looking over something and realizing that you still have some room to grow and figure things out. As a matter of fact, this is a great way to grow as a person and as a programmer. You cannot begin to take steps in the right direction if you don't figure out where you can improve upon the decisions that you have made before.
In my opinion, this gets us one step closer to proper native integration. What do you think? Have you got any comments or suggestions?
Mixing Things Up for a New Creation
Believe it or not, one of the best things that you can do to mix things up and keep your creations fresh is to look at how you can combine native components with the swing components that you bring into the system. It is a way for you to show the people who will ultimately use your creations that you are serious about making something that they stand to benefit from.
If that is the kind of thing that you are into, then you need to give it a try right now. After all, there may be a tremendous number of people just waiting to see what you are all about and what you can offer to them. If you provide them with things to get excited about, then they will keep coming back for more.
Opinions expressed by DZone contributors are their own.