JavaFX – Sudoku with CSS
March 9, 2009 5 Comments
This is a Sudoku game developed using JavaFX. The objective is not really to demonstrate Sudoku, but to show Cascading Style Sheets (CSS) support in JavaFX. This sample uses two CSS files – blue.css and black.css. These files have information about different user interface attributes such as color, font, shape…
For Applet mode, click on above image
First lets create a style sheet…
|
Here we have specified the font attributes family, weight, size, color etc.
Similarly a button can be created by a combination of Rectangle and Text as shown below:
|
Now we need to associate this style-sheet with the top level container of JavaFX – Scene.
|
I have declared a variable stylesheet and have assigned the URL of the stylesheet file. Now I bind this value to stylesheets attribute of Scene. This will associate the CSS file with this Scene. I have used bind so that I can update the associated stylesheet at runtime.
Now I will associate the style-class defined in style-sheet to the specified Node. For example, we can apply the titleText style-class with the title node as shown below.
|
Similarly we can associate the button’s rectangle attributes as shown below..
|
Cool! Now you can play Sudoku game and if you feel bored just change the look and continue playing!!
var dzone_url = “http://blogs.sun.com/rakeshmenonp/entry/javafx_sudoku_css_support”;
var dzone_style = ’2′;
digg_skin = ‘compact’;
digg_window = ‘new’;





Nice can you build some demo about BlendMoes..
Thanks Farrukh. You may refer to "Effects Playground" sample – http://javafx.com/samples/EffectsPlayground/index.html. Click on "Open Image 2" to load the second image. Now select "Blend" option. It will show controls for different modes such as Multiply, Overlay, Difference etc. Hope this helps.
@Farrukh I have posted a new blog on BlendMode – http://blogs.sun.com/rakeshmenonp/entry/javafx_blendmode_effect
Hi Rakesh.
Do you know how can I refer to a relative image url into the css file?
Example:
public class MyClass extends Group{
id:"goBack";
var image:Image{}
…
init {
content = [
...
ImageView{ image:image; }
...
]
}
}
in the css:
…
#goBack.image {
url:url({__DIR__}/images/img.png)
}
…
thakyou for advanced
@Antonio I haven’t tried using image, so not sure if that will work. Need to try..