WidgetFX Experiences
Yannick | September 27, 2009After ending 2nd in the WidgetFX contest, I’d like to share my experiences about using WidgetFX with you.
To be honest, I only created my RadioFX widget one week before the deadline of the contest. I had thought about entering the contest before but I just couldn’t come up with a good idea for a widget that would be useful for a lot of people and not just me as a developer. But as I was creating another JavaFX application that would be able to display information from a Belgian radiostation’s webservice, I thought about how easy it would be to have a small application that would allow me to keep all my urls to various webradios in one place and avoid opening a browser for playback. And that’s when I realized that this would be a good scenario for a widget. So one week before the deadline I started to work on my RadioFX widget during the evenings. This shows that JavaFX allows for pretty fast application development because with little time you can still make cool things!
The features I like most about the WidgetFX framework:
- How easily it allows you to create a widget and save information.
- Sharing your widget with the rest of the world.
- It runs on multiple platforms.
- How easily it allows you to create a widget and save information.
- Publishing your widget to the public is also easy!
- It runs on multiple platforms.
Creating a widget is as easy as initializing a Widget object and returning it from your main javaFX class.
def widget:Widget = Widget {
width: defaultWidth
height: defaultHeight
aspectRatio: defaultWidth / defaultHeight
content: group
configuration: config
resizable: false
}
return widget;
The content attribute contains the code of the visual part of your widget and you can add any javafx code you like.
The configuration attribute is another great feature: it allows you to store configuration parameters for you widget without having to go through all the trouble of having to save them yourself.
You just have to add the parameters as shown in the following sample and they are automatically saved for when you open the widget the next time.
var enableFilter:Boolean;
def config:Configuration=Configuration {
properties: [
BooleanProperty {
name: "enableSearch"
value: bind enableFilter with inverse
autoSave: true
}]
scene: Scene {
width:180
height: 200
fill: Color.web("#282a1f")
content: [
HBox {
spacing: 10
content: [
Text {
font : Font { name: "Arial" size: 12 }
fill: Color.WHITE
content: "Enable filtering"
},
CheckBox {
selected: bind enableFilter with inverse
}
]
layoutX: 30
layoutY: 50
}
]
}
}
Just do as you would normally distribute a JavaFX application but instead of providing direct links to your .jnlp file, you wrap it in a special widgetfx link like this:
<a href=”http://widgetfx.org/dock/launch.jnlp?arg=http://www.jfxperience.com/repo/radiofxj/RadioFXJ.jnlp”><img title=”WidgetFX Launch Icon” src=”http://widgetfx.googlecode.com/svn/site/images/WidgetFX-launch-icon.png” alt=”WidgetFX Launch Icon” width=”82″ height=”25″ /></a>
This will display a nice launch button which will install your widget in the WidgetFX toolbar. If WidgetFX isn’t installed on your user’s computer it will even ask to install it (completely automatic) or launch it if it’s already installed but just not running.
The next step is to announce and share your widget with the rest of the world… This process is made really easy, just submit it to the library on the widgetFX site with a little description on what it does and how it works and after it is approved the whole world will be able to enjoy your wonderful creations!
The widgetFX application runs on Windows, Mac OSX and Linux so this means that you no longer need to write separate Windows Vista or Mac OSX widgets. Just write it once in JavaFX and it will work on all three operating systems. This will save you time on development and maintenance.
One critical note needs to be added though: Not all code runs on all OS. For example, in my RadioFX widget, the playing of streaming audio using the standard JavaFX audio components worked fine on Windows but not really stable on OSX and Linux. Therefore I chose to use a java component that worked fine on all three OS. But this is a JavaFX problem and has nothing to do with WidgetFX.
As you can see, widget development is made easy by widgetFX. I really enjoyed writing my first widget on this cool platform and more will definitely follow!
If you want to try out my RadioFX widget or have a look at the source code, it’s all available right here





