Skip to main content

Slider Example

1 reply [Last post]
pdizzyd
Offline
Joined: 2008-05-08
Points: 0

A question and request for the community out there. I am using NetBeans 6.1 using the nightly builds for the Plugin. I would like know how to handle events on the slider. I am new to all of this and would appreciate a helping hand.

Thanks,

Peter

/*
* Main.fx
*
* Created on Jun 25, 2008, 10:02:32 AM
*/

package newplugintest;

/**
* @author pdouglas
*/

import javafx.gui.*;

Frame {
var phrase:String
var sliderValue:Integer
title: "Chagne Text Size"
height: 300
width: 400
visible: true
content:
BorderPanel {
center:
Canvas {
content:
Text {
x: 50
y: 125
content: "Change the size!"
font:
Font {
size: bind sliderValue
}
}
}
bottom:
FlowPanel {
content: [
Slider {
minimum: 0
maximum: 36
value: 36
orientation: Orientation.HORIZONTAL
}
]
}
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexsch
Offline
Joined: 2007-07-12
Points: 0

Here is a simple example. It uses [b]bind[/b] operator and [b]trigger[/b]:

[code]
import javafx.ext.swing.*;

import javafx.scene.*;
import javafx.scene.text.*;
import javafx.scene.geometry.*;

import java.lang.System;

var sliderValue = 36 on replace{
System.out.println("Slider value has changed: {sliderValue}");
};

Frame {
title: "Chagne Text Size"
height: 300
width: 400
content: FlowPanel {
content: [
Label{ text: bind "Slider value: {sliderValue}" },
Slider {
minimum: 0
maximum: 36
value: bind sliderValue with inverse
orientation: Orientation.HORIZONTAL
}
]
}
visible: true
}
[/code]

Note that GUI packages have been changed:

- Package renaming! You'll immediately notice that just about everything has moved, as we've re-organized package structure significantly. For example: javafx.ext.swing.*, javafx.application.Application, javafx.scene.Node, javafx.scene.paint.Color. It's my job to ensure that anything touched by the hudson builds are adjusted with respect to these changes. But I expect there'll be a lot of you that still need to change your code. We apologize, and we're exploring facilities to make importing the new packages easier.