4 Replies Latest reply: May 24, 2011 6:42 AM by Narayan RSS

    Strange Error

    854171
      Hello guys thanks for your help, but now have this strange error that don't understand.
      I create this simple application, in this application i want to create a rectangle that i see in scene, bur first i open palette.fx, in this file i have3 the butto for create
      rettangle
      /*
       * Mani.fx
       */
      
      package javafxapplication3;
      import javafx.stage.Stage;
      import javafx.scene.Scene;
      import javafx.scene.text.Text;
      import javafx.scene.text.Font;
      import javafx.scene.control.Button;
      import javafx.scene.Group;
      import javafx.scene.shape.Circle;
      import javafx.scene.paint.Color;
      
      /* the variable myBox is public because i access it from myBox2 in palette.fx*/
      public var myBox = javafx.scene.layout.VBox{
               spacing:5
                  layoutX:5
                  layoutY:40      
           }
      
      var g1 = Group {
          content: [
              Button {
                    translateX: 15
                          translateY: 10
                         text: "Palette "
                           action: function() {               
                           Palette{}; // call the palette,
                            
                             }
                     }
              ]
      };
      
      var stage =Stage {
          title: "Application title"
          scene: Scene {
              width: 250
              height:280
              content: [
      g1,
      myBox,
      
      // figura1{}
         ]// end content
      
            }// end scene
                
      }
      
      /*
      *Palette.fx
      */
      
      package javafxapplication3;
      import javafx.scene.Scene;
      import javafx.stage.Stage;
      import javafx.scene.text.Text;
      import javafx.scene.text.Font;
      import javafx.scene.control.Button;
      import javafx.scene.layout.HBox;
      import javafx.scene.shape.Rectangle;
      import javafxapplication3.Main;
      
      
      var myBox2= bind Main.myBox  with inverse;
      
      
      var palet =Stage {
          title:" Palette ";
              scene: Scene {
                  width: 320    
                  height: 230
                      content: [
                 //
                 Button {
                          translateX: 5
                          translateY: 10
                         text: "Rectangel"
                       action: function() {
      
                       insert  {
                             figura1{}; // i call class figura1
                               }into myBox2.content
                           
                              }//fine function
      
                              }// fine Button RETTANGOLO
      
                          ] //content Hbox
      
               }
      }
      /*
      *figura1.fx
      */
      package javafxapplication3;
      import javafx.scene.*;
      import javafx.scene.paint.*;
      import javafx.scene.shape.*;
      
      
      public class figura1 extends CustomNode{
      
       
       override function create():Node {
              return Group {
                  content:  {
                      Rectangle {
                          x: 30
                          y: 30
                          width: 100
                          height: 10
                          fill:Color.RED
                      }
                  }
              };
          }
         }
      when i click on "run main projet" i see this error

      java.lang.NoSuchMethodException: javafxapplication3.Main.javafx$run$(com.sun.javafx.runtime.sequence.Sequence)
      at java.lang.Class.getMethod(Unknown Source)
      at com.sun.javafx.runtime.Entry.start(Entry.java:64)
      at com.sun.javafx.runtime.Main.main(Main.java:80)
      browser-run:
      jws-run:
      midp-run:
      tv-run:
      run:
      BUILD SUCCESSFUL (total time: 2 seconds)

      i think that the problem is this code (present in main.fx)
      public var myBox = javafx.scene.layout.VBox{ ....   }

      but I do not know, how to fix it

      best regads
      A.

      Edited by: 851168 on 23-mag-2011 3.31

      Edited by: 851168 on 23-mag-2011 7.44
        • 1. Re: Strange Error
          Narayan
          Hello user,
          I would like to give some advice.
          Please don't post to the thread unless you have tried it or searched your answer in web.
          If you really intend to post in forum then please format your code properly as properly instructed at here: http://forums.oracle.com/forums/ann.jspa?annID=1462

          You problem is about the main function invocation. To run the main there is no main method in javafx like of java i.e. (public static void main(String[] args)) but there is a function which is invoked firstly in the javafx.
          function run(){
                   //put your execution codes here
                   //the stage variable must be declared at here.
          }
          The above function run() is the main function executor of javafx which helps to run your program.


          Thanks.
          Narayan
          • 2. Re: Strange Error
            854171
            Hello Narayan, thanks for your help,
            i want this:
            - in file main.fx i create a button that open a new scene
            - the new scene born form file palette.fx, in this file i have a button that create a rettangle, this rettangle i want to see in scene born in main.fx

            I am studing the book "javafx developer's guide", in this book i read the possibility to use the binding but i see i can use binding only is the variable are present in same file, in java i can use get and set funcion but in javafx, in main.fx this is not possible, infact the my proble is in this code present in main.fx
            /* the variable myBox is public because i access it from myBox2 in palette.fx*/
            public var myBox = javafx.scene.layout.VBox{
                     spacing:5
                        layoutX:5
                        layoutY:40      
                 }  
            in palette.fx i have:
            var myBox2= bind Main.myBox  with inverse;
            infact if i delete the reserved word public and don't use the file palette.fx, the application work well but don't' use the file palette.fx.
            thx
            A.

            Edited by: 851168 on 23-mag-2011 7.47
            • 3. Re: Strange Error
              Narayan
              Hello user,
              Please start new thread if you have new problem. The post must be specific.
              Help other users to find their problem specific.


              Thanks.
              Narayan
              • 4. Re: Strange Error
                Narayan
                did you use " function run() {} " which helps to invoke your stage either that class contains public or non public variable.

                Thanks.
                Narayan