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
}