Planet JFX
mNo edit summary
No edit summary
Tag: Visual edit
 
Line 9: Line 9:
   
 
Frame {
 
Frame {
title: "Bind Example 2"
+
title: "Add/Sub"
 
width: 300
 
width: 300
 
height: 75
 
height: 75

Latest revision as of 07:34, 4 September 2020

import javafx.ui.*;

class Counter {
	attribute value: Integer;
}
attribute Counter.value = 0;

var count:Counter = Counter {};

Frame {
	title: "Add/Sub"
	width: 300
	height: 75
	content: 
		FlowPanel {
			content: [
				Label {
					text: bind count.value.toString( ),
				},
				Button {
					text: "Add 1"
					action: operation () {
						count.value = count.value + 1;
					}
				},
				Button {
					text: "Subtract 1"
					action: operation () {
						count.value = count.value - 1;
					}
				}
			]
		}
	visible: true
}