Monday, September 22, 2014

JavaFX 8 ColorPicker to fill Background

JavaFX 8 example to implement ColorPicker and set background color on Action EventHandler.

package javafxcolorpicker;

import javafx.application.Application;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ColorPicker;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Paint;
import javafx.stage.Stage;

 * @web
public class JavaFXColorPicker extends Application {
    public void start(Stage primaryStage) {
        StackPane root = new StackPane();
        ColorPicker colorPicker = new ColorPicker();
        colorPicker.setOnAction(new EventHandler(){

            public void handle(Event event) {
                Paint fill = colorPicker.getValue();
                BackgroundFill backgroundFill = 
                    new BackgroundFill(fill, 
                Background background = new Background(backgroundFill);

        Scene scene = new Scene(root, 300, 250);
        primaryStage.setTitle("Hello World!");

    public static void main(String[] args) {

Friday, September 19, 2014

JavaFX Rich Client Programming on the NetBeans Platform

JavaFX Rich Client Programming on the NetBeans Platform

JavaFX is a state-of-the-art graphics toolkit that is now built into Java and can be easily integrated with the NetBeans Platform. With JavaFX, you can create advanced user interfaces, manipulate media, generate graphical effects and animations, and much more. The NetBeans Platform provides a framework for building robust, modular applications with long life expectancies. Together, JavaFX and the NetBeans Platform provide the basis for creating visually appealing, industrial-strength applications.

Focusing on JavaFX as the front end for rich client applications, this guide’s examples cover JavaFX 8 with the NetBeans Platform, NetBeans IDE, and Java 8. Gail and Paul Anderson fully explain JavaFX and its relationship with the NetBeans Platform architecture, and systematically show Java developers how to use them together effectively. Each concept and technique is supported by clearly written code examples, proven through extensive classroom teaching.

Coverage includes
  • Background basics with Java, JavaFX, and UI events
  • Building loosely coupled applications
  • NetBeans Platform Modules and Lookup
  • NetBeans Platform Nodes, Explorer Views, and Actions
  • Building CRUD-based applications
  • Integrating JavaFX with a Swing-based framework
  • Using JavaFX Charts with the NetBeans Platform
  • Using the NetBeans Platform File System and Data System
  • Keeping the UI responsive

Tuesday, September 16, 2014

Example of getSimpleName()

The getSimpleName() method returns the simple name of the underlying class as given in the source code. Returns an empty string if the underlying class is anonymous.

This example modify from last post to list superclasses with simple name.

package javagetsuperclass;

 * @web
public class JavaGetSuperClass {

    public static void main(String[] args) {

        JavaGetSuperClass me = new JavaGetSuperClass();
        SubJavaGetSuperClass subMe = new SubJavaGetSuperClass();
        Class testClass = javafx.scene.chart.AreaChart.class;

    public void doSomething(){
    static private void printClassInfo(Class someClass){

        StringBuilder info = new StringBuilder();
        info.append("someClass: ").append(someClass).append("\n");
            someClass = someClass.getSuperclass();
                info.append("superClass: ").append(someClass.getSimpleName()).append("\n");
                info.append("superClass: ").append("null").append("\n");
        }while(someClass != null);


class SubJavaGetSuperClass extends JavaGetSuperClass{