Adding Look and Feel for Swing Based UI ?

After quite a while, I thought of writing a Blog post based on Java Swing Development and I thought of writing something cool as well as simple. Improving Look and Feel in a Java Swing based UI could be a simple but necessary thing because it could improve the quality of your application inside and out. 

In order to do this, the best thing to do is to download and add Java Synthetica Addons, because they're easy to apply on the current working project of yours. But, there's this little problem of Synthetica Addon is not to be distributed for free.

But, there's a good news and a bad news. The good news is that there's a lot of Free download links to download these Synthetica Jar Archives, yet the bad news is that they're older and most often doesn't work with the newer versions of java.

Then, how to download the newest cool improved version of Synthetica Addons and often at the same time make them not to show Watermarks like they usually do. Let's explore the Clear step wise explanation of Adding New Synthetica to the Java Swing UI.

I'm using Net beans as my Integrated Development Environment in order to perform this task. No matter what you use as your IDE, you can follow the steps as follows.

Step 01

First, create a new Project as of 'Some Name'. In my case, it's UI.


Step 02

Add a JFrame of your Liking and write the following Piece of Code inside the main static method of the 'Project Name'.java's 'Project Name' class.

            java.awt.EventQueue.invokeLater(new Runnable() {

                public void run() {
                LookAndFeel look;
                try
                {
                    look = new SyntheticaStandardLookAndFeel();
                    UIManager.setLookAndFeel(look); //calls setLookAndFeel static method
                    new First().setVisible(true); // First is the JFrame that I've created
                }
                catch(Exception ex)
                {
                    ex.printStackTrace();
                }
                
            }});


I'd like to explain few of the Self evident factors regarding this piece of code that I've given above. The Frame contains an UI thread, but the invokelater method of the EventQueue Class of the Java abstract window toolkit (awt)  package updates the Frame's UI thread. Runnable is an Interface which includes a run method, but the declaration and implementation of the run() method, the run method of the original interface is overridden. Inside it, an object of the LookandFeel class of swing package is stored with an instance of the SyntheticaStandardLookAndFeel class. In the next line, a Static method has been called without creating an object from UIManager Class as  creating objects is unnecessary when it comes to calling static methods. Surrounding, it with a TryCatch is important as there should be a way of Catching Exceptions.



Step 03

In order to avoid the references problems you've to download, the Synthetica Packages from the jyloo.You can then unzip the Downloaded Zip file & then try to add the Jars as libraries into the Project by right clicking in the Project Explorers Library Folder and add Jar Option. You've add Synthetica.jar.


Step 04



When running the Project, it seems that the Synthetica has been applied with the Water Mark stating that 'Synthetica' is an "Unregistered Evaluation Copy". Then, the problem is how to remove this watermark. I've included the steps of doing that.

Step 05

Download and unzip the 'rej' which enables us to edit the Synthetica.jar and make the Synthetica Unregistered Evaluation Copy Message Disappear. Then, run rej.jar by double clicking it. Open the Synthetica.jar inside the Project folder.


Then, Select the 'de/javasoft/plaf/synthetica'.



Then, select 'SyntheticaRootPaneUI.class' and double click it and open it.



Step 06

Then press Ctrl+F to find the Method 'isEvalCopy' method.


After finding the relevant Method as shown in the Image itself, right click on 'iconst_1 1' and click insert after. Then in the coming dialog box choose 'iconst_0 0'. 



Now, remove 'iconst_1 1' and save the changes made to .jar.





Step 07

Finally, take the search tab and Search for the term 'invalid' by typing it in the search bar.



Pick the 4th From the Top Search result which is 'Instruction : de.javasoft.plaf.synthetica.SyntheticaLookAndFeel$1.showDialog .....' , and double click on it.


Step 08

You'll find the showDialog() method and remove the whole content inside it, but make sure that the method has only 'return' statement in it.


That's all. Now, you can rebuild the Project and Run it. You'll find the Synthetica applied to the Swing application without 'The Water mark'. That's something.

9 comments:

Anonymous said...

I can't believe how old this is and yet still worked like a charm. Thanks!

Anonymous said...

thanks

Anonymous said...

thanks a lot

Anonymous said...

Thanks man

Anonymous said...

Nice artical. Thanks

Anonymous said...

thanks

Mayana said...

I cant belive its work so well, thanks a lot

Anonymous said...

I cant belive its work so well, thanks a lot

Unknown said...

I applied your solution. It removed the License text but the panel which contains that text still exists there. Please Help