• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems switching scenes

 
Roger Wells
Ranch Hand
Posts: 51
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having problems getting the scenes to switch. The starting initial scene at 70-73 works and I can change to have either scene work by changing line 70 to bpFormater or bpInitial

Lines 213 - 218 I think somewhere I still have a problem with scope?

Any help would be appreciated
Roger

 
John Damien Smith
Ranch Hand
Posts: 296
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get your bpFormater scene to display.

In your start method record the stage and create a bpFormater scene:



Note, I also changed the name of the bpFormater which is class scoped from bpFormater to bpFormaterScene, to prevent confusion with the locally scoped bpFormater variable.

Display the scene:


That should allow you to get your scene to show up.

There are a few other recommendations that I would make (the code will work without these):

1. Use camel case naming conventions (https://google.github.io/styleguide/javaguide.html#s5.3-camel-case), e.g. start method names in lower case.
2. Don't use a common ButtonClicked method which evaluates to a long set of if statements.  Instead just invoke an individual method for each method call:
    Instead of:
        buttonAdd.setOnAction(e -> ButtonClicked(e));
    Write
        buttonAdd.setOnAction(e -> add());
    Where add is a new method you create.
3. Split your screens up into different classes, with a class per screen, so you would have a BpFormatter class and a BpInitial class.
    Note, using FXML and controllers in conjunction with SceneBuilder can assist in the split-up by scene as normally an FXML has a 1:1 relationship with a scene controller.
4. Use CSS stylesheets for style rather than inline style specifiers.
5. Formatter is spelt Formatter not Formater.

The above is just some advice you can try incorporating bit by bit as you get more advanced.  For now, it's probably best to focus on getting what you have working at a minimal level as you wish :-)




 
Roger Wells
Ranch Hand
Posts: 51
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Thanks I got it to work. I think I will re-write the whole project as it is a learning process for me.

Can you give me a example of how to split my scenes into different classes? Just something simple?
Thanks
Roger
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic