torsdag 8. november 2012

JavaFX - FXML ... "Root value already specified."

"Curiosity killed the cat you know". Tim Burtons fantastic movie Nightmare Before Christmas, and this quote from Doctor Finklestein comes to mind. The movie is about Jack Skellington, the Pumpkin King of Halloween Town, who discovers Christmas. And what a mess that becomes, since he doesn't quite understand what Christmas is.

Trying to be clever usually gives me a lot of hassle, so I guess I can relate to this Jack Skellington character.

Here I am, trying to create a nifty JavaFX CSS Demo. But why choose the easy path? "I should try do this with FXML which I haven't looked at yet". It had to go wrong right?

Have you tried Google this?
Caused by: javafx.fxml.LoadException: Root value already specified.

I guess I might be the first to try explain this on the entire internett ... *sigh*

JavaFX - CSS tips


There is a few blogs and tutorials about how to CSS style your magnificent JavaFX application already, so there is no point for me to duplicate that. I have made an small example where I have explored styling a bit.


This is of course a simple example, so I was thinking of sharing a few tips, tricks, a bit of code and some ramblings on the matter.

søndag 28. oktober 2012

JavaFX WebView size trick


JavaFX comes with a web browser component called WebView. It is based on the open source WebKit browser, which bring tremendous power to Java.
But when you try to use it as a regular component like the Text and want to make it fit within the other components it can be quite a challenge to make it behave. Especially when you don't want to use it as a traditional "surfing the web" browser, but as a component to show more or less static HTML content.

Text will size out between min and max, and try to honor the preferred size and squeeze in where there is place. JavaFX will use its magic to make that happen. WebView is a shell that will kind of fit based on its parent, but the internal Webkit will size up based on its own calculation of the HTML/CSS/JS content, and a scrollbar will pop up when needed. The link between WebView and Webkit seems weird in light of how the rest of JavaFX works.

Lets make it behave, shall we?

JavaFX 2.x - Bindings and Properties


JavaFX comes with a couple of cool features which Swing doesn't have. Instead of using literals like int, double, string etc, JavaFX comes with properties. The content in a Textfield is found in the textProperty() which happen to be a StringProperty class. You can get the string, but you can also do binding or adding listeners.

This is a nice way of reducing boiler plate code, and it gives the opportunity for creative solutions.

søndag 30. september 2012

JavaFX 2.2 - The Swing Replacement

JavaFX started its life as DOA. Dead On Arrival. Rumors of being slow, its own script language, RIA competitor, etc. There was no reason to waste time having a look at it. There was no reason to use it since RIA software began a decline.

The new v2.0 was released October last year with nobody noticing. When the new version, v.2.2 released this summer, I sat down and had a look at it. Having previously worked on a  Java Swing project, I had to have a look, and I was surprised of all the new features..

mandag 10. september 2012

HTML5 Websocket with Apache Camel

  I have made a few HTML5 Websocket examples with Apache Camel 2.10, Spring 3, Dojo Toolkit 1.7.3, and Maven. The applicaton is made runnable as a Servlet, making the demo portable.

It is very simple to make a websocket application with Apache Camel. That is actually crazy since Apache Camel is an integration framework, made for dead boring jobs of making boring computer systems communicate with each other.
Actually - Apache Camel is boring... until I discovered all the crazy possibilities with Camel.

søndag 9. september 2012

About

Why yet another blog about technical stuff Java?

First of I would like to create a place where I can drop in "notes to myself". I do figure out stuff, or find stuff on the internet which I find useful. All of this end up in my brain which is quite a crowded place already, and it is getting harder to remember all of this when our silly industry happens to create loads of exciting stuff every day.

I am an norwegian Java developer, and have been so since 2007. Previous I have worked with technical IT support and have had computers as my hobby since 1995.

Java No Makanaikata is Japanese, and I think it translate to something like "Java Cook". Its hard to create useful blog addresses when everything is pretty much taken :)

v1.1 - 09.sept.2012