1

I am trying to quickly create a mock up app using CODENAME ONE

I am finding the resource editor difficult to understand.

1) I create a form and place a button on it.

2) I created another form with the message "Hellow World"

3) I add an action event to the button on FORM 1 using the resource editor and netbeans opens up with a method implementing that action.

4)Now I wish to write in that method some code to display form2 ("Hello World") . How do i do this?

Q1) How do i refer the object of form2 in this case?

Q2)Also, on the display of form2 , I wish to add a textbox on it. how do i do this using resource editor?

My basic question is how can we reference elements created by resource editor via CODE?

Nikhil
  • 1,279
  • 2
  • 23
  • 43

2 Answers2

4

The simplest thing is to set the button as a Command and just select the destination form in the action (notice this will effectively disable the action event).

Alternatively you can call: showForm("formName", null); from code.

To add elements to an existing form you need to decide where they should be. E.g. the destination form has a Container where you want to place the TextArea?

Just name that Container in the GUI builder as "MyDestContainer". Now when you want to add the text area you can get a pointer to the Container by using something like:

 Container dest = findMyDestContainer(Display.getInstance().getCurrent());
Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • I think there is a bug here. I tried this: 1)Declare two forms , Form1 and Form2 . 2)Add an event postShow for Form2. 3)BUT,..The above event for Form2 is called before the form2 is actually shown on the display. Hence, the statement : Container dest = findMyDestContainer(Display.getInstance().getCurrent()); FAILS!(returns null). This is because, the form which is currently active on the the screen is still Form1.(Despite calling showForm("Form2"),null). 4)Finally, when form2 is visible on the display, NOTHING HAPPENS, because postShow for form2 has already occurred. – Nikhil Jul 03 '12 at 16:47
  • You need to invoke find when form2 is showing. Do it in the before form2 event. You need to preserve state in order to "know" what to add to which form. – Shai Almog Jul 03 '12 at 19:54
  • Exactly! I am trying to invoke 'find' when form2 is showing. However'r form2's Post Show event is occurring BEFORE form2 is shown. Hence the find is not working. I tried 'find' in form2's before show event too..that did not work(i think its not supposed to work here anyway...because its finding BEFORE the form2 is active on the Display). – Nikhil Jul 04 '12 at 01:45
1

you can do for this wave

enter image description here

showForm("Ingreso_Recibo", null);