Fandom

Planet JFX

Introduction to Binding: Example 4

118pages on
this wiki
Add New Page
Talk1 Share
import javafx.ui.*;

class Counter {
	attribute value: Integer;
	operation increase( );
	operation decrease( );
}

attribute Counter.value = 0;

operation Counter.increase( )
{
	value++;
}

operation Counter.decrease( )
{
	value--;
}

var count:Counter = new Counter( );

Frame {
	title: "Bind Example 4"
	width: 300
	height: 75
	content:
		FlowPanel {
			content: [
				Label {
					text: bind count.value.toString( ),
					foreground: bind
						if (count.value >= 0) then
							black:Color
						else
							red:Color						
				},
				Button {
					text: bind "Add 1"
					action: operation( ) {
						count.increase( );
					}
				},
				Button {
					text: bind "Subtract 1"
					action: operation( ) {
						count.decrease( );
					}
				}
			]
		}
	visible: true
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.