Java ME - multiple forms moving from one screen to another

I am using Java Micro Edition and I am trying to create a simple login form to the record store. When a user enters details, I would like to check them for saved ones, and then move them to another screen as a welcome area.

I have a feeling that it has something to do with the form element and switches between it, but I can’t go anywhere with google

+4
source share
2 answers

displays what should be created in the constructor, as well as above it ie

public class YourMidlet extends MIDlet implements CommandListener { private Display display; private Form form1; private Form form2; public YourMidlet { display = Display.getDisplay(this); form 1 = new Form("hello form this is form 1"); form 2 = new Form("hello form 2"); display.setCurrent(form1); } } 

you do:

 display.setCurrent(form2); 

to go to form 2

+3
source

try it

 form = new Form("login"); form.addCommand(getExitCommand()); form.addCommand(getOkCommand()); form.setCommandListener(this); public void commandAction(Command command, Displayable displayable) { if (displayable == form) { if (command == exitCommand) { exitMIDlet(); } else if (command == okCommand) { display.setCurrent(getWelcomeForm()); } } else if (displayable == form1) { if (command == backCommand) { // do something else } } } 
+5
source

Source: https://habr.com/ru/post/1303057/


All Articles