2

I'm currently working on building my first app. :) I've now coded several Forms, each in an own class. Now, I want to implement the navigation from one Form to another, this is pretty straight forward since there is always only one "next" Form for every Form currently.

So i tried to do this by adding a "nextForm" Form to every Class and I want nextForm.show() every time the "next" Button is pressed. I tried it this way:

login = new Button("Login");
    login.setUIID("nxtButtons");
    login.addActionListener((e) ->
            nextForm.show()
    );

So, when i actually click the button, nothing happens.

Is the way I try to code this a good way? This is the first time Im heading into GUI building and I don't have experience here yet. Maybe one of you guys could help me here :)

Thank you very much

Kind regards,

Max

Max R.
  • 1,574
  • 2
  • 12
  • 27
  • 1
    I recommend you to use multiple panels over forms. – Nikolas Charalambidis Oct 02 '16 at 15:31
  • As @NikolasCharalambidis says, and as most all Swing experts will agree, don't throw a bunch of JFrames at the user as they won't like this design. Instead swap views. Please see: [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/questions/9554636) – Hovercraft Full Of Eels Oct 02 '16 at 15:32
  • Hi, im talking here about the Codename One Stuff, I'm not using swing. – Max R. Oct 02 '16 at 17:54
  • I nominated this to reopen as this is obviously not a duplicate (Swing guys please read the question first it literally starts with Codename One and is properly tagged)... I'm assuming `nextForm` is null and you should see the null pointer exception in the console somewhere. If not nextForm might be pointing at the current form which will do nothing. You can place a breakpoint on that line in the debugger and see that the breakpoint is reached then inspect the values of the variables – Shai Almog Oct 03 '16 at 03:15

1 Answers1

1

I'm assuming nextForm is null and you should see the null pointer exception in the console somewhere.

If not nextForm might be pointing at the current form which will do nothing. You can place a break point on that line in the debugger and see that the break point is reached then inspect the values of the variables.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65