Amino + Swing = Crazy Delicious

For the past few months I've been working on an open source UI toolkit called Amino. It has lots of cool features like a scenegraph, CSS control skinning, and dynamic translation editing. You just have write your app in Amino and you get the cool stuff for free. But what if you have an existing Swing application and don't want to rewrite it? Don't worry, Amino's got you covered.

Amino now has beta integration with Swing. You can drop any Amino scene into a Swing panel, then mix it with the rest of your app. The key is the JComponentWrapper class, which implements JComponent and contains Amino Nodes.


Rectangle aminoRect = new Rectangle(0,0,20,20).setFill(FlatColor.BLUE);
JComponentWrapper wrapper = new JComponentWrapper();    
wrapper.setContent(aminoRect);    
JPanel panel = new JPanel();    
panel.setLayout(new BorderLayout());    
panel.add(wrapper,BorderLayout.CENTER);

That's all you have to do. JComponentWrapper will process all of the repaints and map Swing events to Amino events. Here's a screenshot of a more complicated example that embeds a custom Amino chart in the middle of a frame with other Swing components.

org.joshy.gfx.test.swingintegration.SwingChartDemoScreenSnapz001.png

To learn more about Amino, you can:

Talk to me about it on Twitter

Posted December 9th, 2010

Tagged: java.net