Fandom

Planet JFX

Simple Internal Frame Example

118pages on
this wiki
Add New Page
Talk0 Share

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.

This is example of an internal frame. (Old code does not work in JavaFX 1.3)

200.39.8.121 15:13, August 18, 2011 (UTC)Edit

import javafx.ui.*; import javafx.ui.canvas.*; import javafx.ui.filter.*; import java.lang.Math;

class Wind {

 attribute angle:Number;
 attribute sAngle:Number;
 attribute tAngle:Number;
 public operation setAngle(nAngle:Number);
 public operation zero();
 public operation random();

}

operation Wind.setAngle(nAngle) {

 tAngle = nAngle;
 sAngle = angle;
 angle = [sAngle..tAngle] dur Math.abs(tAngle-sAngle)*2 linear;

}

operation Wind.zero() {

 setAngle(0);

}

operation Wind.random() {

 setAngle((Math.random()*360).intValue());

}

class Windsign extends CompositeNode {

 attribute wind:Wind;

}

function Windsign.composeNode() =

 Group {
   var x = 50
   var y = 50transform: bind translate(x, y),
   onMouseDragged: operation(e) {
     x += e.localDragTranslation.x;
     y += e.localDragTranslation.y;
   }
   toolTipText: "You can totally drag me around!",
   content: [
     Circle {
       cursor: HAND,
       cx: 50,
       cy: 50,
       radius: 50,
       fill: cyan,
       stroke: blue,
       strokeWidth: 2,
     },
     Polygon {
       points: [50,0,
         55,98,
         50,95,
         45,98]
       fill: darkblue
       transform: bind rotate(wind.angle,50,50)
     }
   ]
 };
 Frame{
   var wind = Wind {}
   var ws = Windsign { wind:wind }
   title:"Windsign"
   background: white
   visible:true
   content:
     BorderPanel {
       top: FlowPanel {
         background: white,
         content: [
           Slider {
             min: 0,
             max: 360,
             minorTickSpacing: 15,
             majorTickSpacing: 45,
             paintTicks: true,
             value: bind wind.angle,
           },
           Button {
             text: "Zero",
             action: operation() {
               wind.zero();
             }
           },
           Button {
             text: "Random",
             action: operation() {
               wind.random();
             }
           }
         ]
       }
       center: Canvas {
         background: white
         content:ws
       }
     }
   }

Also on Fandom

Random Wiki