Nine-patch editor within the library

 

It have been a long time since last post here, but from now on i will also inform you about upcoming features with separate posts.

Today i will tell you some news and interesting information about upcoming features and would love to see any kind of feedback in the comments or on email!

9-patch

There was a small announce of a new visual editor for Android 9-patch format on HabraHabr which is now a part of  Web Look and Feel library (and could be found in upcoming release or in the post on HabraHabr). If you are Android developer – that might be interesting for you since it is much more comfortable and easy in use than a basic editor that is offered to Android developers.

Also with upcoming release there will be a cross-platform installer available on downloads page for desktop 9-patch editor version so Android developers can quickly install and use it.

So, what about Swing?

I bet you will ask – “how is this even connected with desktop Java and Swing on which Web Look and Feel library is based?” – i will try to answer that question… Since 9-patch have proven its usefulness and ease of use on Android platform, i decided to add it as one of styling options of every Swing component. This means that you can quickly style any Swing component (button, tabbed pane, combobox or anything else) by using simple png files with 9-patch marks made right on the image (that is what a 9-patch file basically is).

I have already attached this feature to some of base components and i could say that it works amazingly good and should be a pretty powerful feature in desktop applications development! The result is not perfect yet, but i will polish it soon enough and will release the first  library version with styling support right away.

For now there will be styling support for next basic Swing components:
JLabel, JPanel, JButton, JToggleButton, JTextField, JPasswordField, JFormattedTextField, JTextArea

With next update or two support of all of the rest Swing components will be added.

Going deeper

By adding 9-patch styling feature to Swing components i still didn’t want to make it the only way to style them.
So this feature is based on another one (which is more abstract) – background painters concept.

Basically, every Swing component (or it’s parts) can be split into different states which appear after some of user/data-change actions.
It could be pressed button state, unselected disabled checkbox state, normal panel state or any else – there is actually a lot of those.
So if we split Swing components into different (known) states we could style every state separately (in the particular case with the 9-patch resources help).

And here BackgroundPainter comes in – it is a simple interface which draws a single state for single component or it’s part.
It has a lot of default implementations like NinePatchBackgroundPainter and such which will make the deal a lot easier.

Ofcourse that is only an idea – it’s full implementation is hidden deep inside the last Web Look and Feel library version and will be soon available here :)

So, when will it be?

In worst case i will release new version at the end of this month, but i still believe things could go better and it will be available this week already.
At the moment i am finishing some last changes over the demo-application so it will be twice better and could be used as a code-tip like its made in many other popular libraries.

This version actually took me a lot of time to develop it due to a giant pool of features that will come with it and also due to a lot critical changes and fixes inside the library and also due to the fact that i changed the code five or six times to achieve better usability of the features that are coming. So this release will not be only about 9-patch and components styling – there will be also a big set of new features and component. I hope you will enjoy it!