form.java never used by main java program. All examples given just use main java program for code. (hover over form.java class name and it says class never used)

38 views
Skip to first unread message

Charles G

unread,
Dec 8, 2019, 4:09:03 AM12/8/19
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator
Device

Shai Almog

unread,
Dec 8, 2019, 8:58:28 PM12/8/19
to CodenameOne Discussions
You need to use the form somewhere in the app e.g. in the start() method of the main class.

Charles G

unread,
Dec 9, 2019, 3:23:11 PM12/9/19
to CodenameOne Discussions


On Sunday, December 8, 2019 at 4:09:03 AM UTC-5, Charles G wrote:
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: IDEA
linux
Simulator
HP laptop

public class MyForm5 extends com.codename1.ui.Form {
public MyForm5() {
this(com.codename1.ui.util.Resources.getGlobalResources());
}

public MyForm5(com.codename1.ui.util.Resources resourceObjectInstance) {
initGuiBuilderComponents(resourceObjectInstance);
}
 
what is
resourceObjectInstance

Shai Almog

unread,
Dec 9, 2019, 9:07:14 PM12/9/19
to CodenameOne Discussions
You can pass an instance of the Resource class if you wish. If you don't we'll implicitly use the default one (see the default empty constructor).
Resources class includes the content of the .res file which includes the images, themes etc.

Charles G

unread,
Dec 9, 2019, 11:47:00 PM12/9/19
to CodenameOne Discussions
you need to use the second constructor in order to use the
private void initGuiBuilderComponents(com.codename1.ui.util.Resources resourceObjectInstance)
procedure which contains all the generated code
private void initGuiBuilderComponents(com.codename1.ui.util.Resources resourceObjectInstance) {
setLayout(new com.codename1.ui.layouts.LayeredLayout());
setInlineStylesTheme(resourceObjectInstance);
setScrollableY(false);
setInlineStylesTheme(resourceObjectInstance);
setTitle("MyForm5");
setName("MyForm5");
addComponent(gui_Label);
addComponent(gui_Radio_Button);
addComponent(gui_Button_1);
gui_Label.setText("my hello world");
gui_Label.setUIID("Label5");
gui_Label.setInlineStylesTheme(resourceObjectInstance);
gui_Label.setInlineAllStyles("font:6.0mm;");
gui_Label.setName("Label");
etc. which uses
resourceObjectInstance

Charles G

unread,
Dec 10, 2019, 1:33:46 AM12/10/19
to CodenameOne Discussions


On Sunday, December 8, 2019 at 4:09:03 AM UTC-5, Charles G wrote:
If you are experiencing an issue please mention the full platform your issue applies to:
IDE:IDEA
linux
Simulator
Device

Shai Almog

unread,
Dec 10, 2019, 9:14:06 PM12/10/19
to CodenameOne Discussions
Notice that the first constructor calls
this(com.codename1.ui.util.Resources.getGlobalResources());

That means it invokes the second constructor. This is called constructor chaining, it's effectively invoking the other constructor with the global resources.
Reply all
Reply to author
Forward
0 new messages