Tuesday, May 19, 2009

Domain Driven Swing Framework

Hello my readers,

Nowadays, I am putting all of my efforts to make swing application as sexiest as one could ever imagine and as simplest as a piece of cake. To make swing desktop application as an agile and a romantic piece of work, I have now started my work on my Domain-Driven-Swing Framework.

Domain-Driven-Swing framework is generated dynamically on fly based on Domain Object, Domain Data and XML structure. Every entity of the domain related info either it is Domain Object , domain data or XML is binded with Generated UI with the help of JGoodies binding mechanism. I used Map binding concept.

When auto-generated Panel is created then it will be injected to the FormContainer which will be wired by the componentID. ComponentID is the unique identifire of the components and usecases which will be used widely to recognize any action, any updates and any validations.

This whole framework is developed on totally de-coupled mechanisim like Message-Mailbox concept. Every activity is controlled by some Manager who is listening to its respected activities.

Validation is done at two levels i.e. Beans/ Data level and UI level. For Bean/Data level I am using hibernate validator and for UI, I used JComponent's method setInputVerifire().

For Look and Feel, I have used substance as Decoration provider.

This is my first blog entry of few series of introduction to my domain/data driven swing framework.

Cheers, and it will be my promise to you all that InhsaAllah, I will comeup with new blog enteries with screen shots and examples of how to use this framework very soon.

This framewok is almost 60-70% in the completion stage.

Ciao

Changing the Look and Feel of the swing application at runtime

Hi,

I have found an exciting feature to put in the desktop based swing application to change its look and feel on fly with some action associated with some look and feel changing buttons.

You need to create a button and assign an action listener to it. In the "actionPerformed" method of the listener, write down the following code and enjoy the magic...

public void actionPerformed(ActionEvent e) {

try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
Frame frame = WindowManager.getDefault().getMainWindow();
SwingUtilities.updateComponentTreeUI(frame);
frame.pack();

} catch (Exception ex) {
ex.printStackTrace();
}
}


cheers


Tuesday, May 5, 2009

ICeFaces open sources its pdf renderer

Hi All,

ICEFaces big name in the Ajax based JSF components has open sourced its famous pdf viewer component. Its commerical part only has additional Font engine.

In this post, I am posting an example about using ICEPdf viewer library for swing applications as I am a big fan of swing rich clients.

public class ViewerComponentExample {
public static void main(String[] args) {

// Get a file from the command line to open
String filePath = args[0];

// build a component controller
SwingController controller = new SwingController();

SwingViewBuilder factory = new SwingViewBuilder( controller );

JPanel viewerComponentPanel = factory.buildViewerPanel();

JFrame applicationFrame = new JFrame();
applicationFrame.getContentPane().add( viewerComponentPanel );

// Now that the GUI is all in place, we can try openning a PDF
controller.openDocument( filePath );

// show the component
applicationFrame.pack();
applicationFrame.setVisible(true);
}
}

Actually, this example is taken from the ICEPdf distribution. It is a well-explained example. I found this example as very easy to use and it has all required features we usually need in PDF viewer.

Before this api, I was using Adobe abandoned "bean" project which has very old version of pdf render. I also tried pdf-renderer project hosted by java.dev.net. I found this library as very optimised and well-coded.

Cheers and enjoy ICEPDf