This discussion is archived
0 Replies Latest reply: Jun 5, 2011 12:49 AM by 854171 RSS

Traslation problem

854171 Newbie
Currently Being Moderated
hi to all, thx for your help
i write this simple applicatin, this application create a rectangle, i want traslate this rectangle but don't' work.
I change th variable myBox in javafx.scene.layout.Flow but don't work, where is the problem can you help me?
best regads
Antonio
// main.fx
public var myBox = javafx.scene.layout.HBox{
         spacing:5
            layoutX:15  
           layoutY:40  
     }

//var myBox=bind javafxapplication1.Palette2.myBox2 with inverse;
var g1 = Group {
    content: [
        Button {
              translateX: 15
                    translateY: 10
                   text: "Palette "
                    action: function() {             
                        Palette{};
                       }
               }

            
        ]
};

var stage =Stage {
    title: "Application title"
    scene: Scene {
        width: 250
        height:280
        content: [
g1,
myBox,
  ]// end content

      }// end scene
}
// run the application

function run () {
    stage
    }
     
          
     // palette.fx
     public class Palette extends CustomNode{


var myBox2=bind javafxapplication4.Main.myBox with inverse;
public var i=10.0;
    
var palet =Stage {
    title:" Palette ";
        scene: Scene {
            width: 320
            height: 230
                content: [       
                
           Button {
                    translateX: 15
                    translateY: 35
                   text: "Rectangel"
                 action: function() {                                  
            insert  {

                       figura1{}; // i call class figura1
                         }into myBox2.content;
           
                        }//end function i

                        }// end Button Rectangel
                              ] //content Hbox

                    }
               }

    }
     
     
               
// figura1.fx -in this file i create rectangle 
public class figura1 extends CustomNode{
//var y=10.00;
//var x=10.00;
override function create():Node {
           return Group {
            content:  {

                Rectangle {
                    
                    x:10
                    y:10 
                    width: 30
                    height: 20
                    fill:Color.RED
                  transforms: Transform.translate(30,30);
                 onMouseEntered: function(e) {
               // x=x+5;
               // y=y+5;
                }   
               }   
             } 
            };// fine group
    }

   }

     

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points