Posts Tagged bind

How to bind vertical scroll in multi tableview

Hi javafx folks,

Today I will show how to make your multi table view bind with a single ScrollBar. JavaFX is becoming more and more powerful and nowadays people are using this javafx for comaparing the data between tables and it’s pretty much helpful for scrolling the tables with a single Scrollbar.

To make this things happen ; Firstly I have dived to check if there is any api for making scroll binding in both tables but I didn’t find them. I then went to see if there is any manual scroll of the tableview finally i found them scrollTo(int) which is really helpful for the programmer to scroll the tableview manually.

Lets first see how we are going to make this happen.
Read the rest of this entry »

Tags: , , , , , , ,

Updated Date and Time in JavaFx (Bind)


/*
 * Class : DateTrack.fx
 *
 * Created on Nov 20, 2009, 3:35:25 PM
 *
 =============================================================
 This program will update the date of your current System Date
 Now we are tracking date via help of UTILITY CLASS "DATE"
 and we are taking advantage of the Timeline and init()
 If any thing goes wrong then please comment me
 ==============================================================
 */

package practice;  // you can change as per your package

//Import Directives...
import java.util.Date;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;

/**
 * @author NARAYAN
 */
//--------------------
//Variable declaration
//--------------------

var myDate = "";  // just initializing..

//This will execute init() of Clock Class
var myClock = new Clock(); 

//Declaring Class Clock for updating Date
class Clock {
    public function nextTime() {
        var now = new Date();
        myDate = "{%tEc now}";
        /*
        * {%tEc now} is the extended format used
        * for the java.util.Date object ("now").
        *
        * %tx - Localized date
        * %tX - Localized time
        * %tu - A day of the week (1-7, 1 is for Monday)
        * %tEx - Locale's alternate date representation
        * %tEX - Locale's alternate time representation
        *
        */
    }

    // THIS WILL BE EXECUTED AT FIRST...
    init { //INITIAL
        var time = Timeline {
            repeatCount: Timeline.INDEFINITE
            keyFrames: [
                KeyFrame {
                    time: 1s
                    action: function() {
                        nextTime();
                    }
                }
            ]
        }
        time.play(); // TAKING ACTION TO PLAY
    }
}

Stage {
    title: "Application title"
    width: 250
    height: 80
    scene: Scene {
        content: [
            Text {
                font : Font {
                    size : 16
                }
                x: 10
                y: 30
                // Binding the current date
                // which helps to show updated date
                content: bind {myDate};

            }

        ]
    }
}

Tags: , , , , ,