Wikia

Planet JFX

Introduction to Binding: Example 3

118pages on
this wiki
Talk1
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 3"
	width: 300
	height: 75
	content: 
		FlowPanel {
			content: [
				Label {
					text: bind count.value.toString( ),
				},
				Button {
					text: "Add 1"
					action: operation( ) {
						count.increase( );
					}
				},
				Button {
					text: "Subtract 1"
					action: operation( ) {
						count.decrease( );
					}
				}
			]
		}
	visible: true
}

Around Wikia's network

Random Wiki