I suppose that my CN1 plugin is up to date (I had an automatic update
notification 2 or 3 days ago). I tested in eclipse and Netbeans with the
same result
my CN1 libs are also up to date (but just to be sure, I performed a new
"refresh CN1libs libs" but that didn"t change anything)
I found how to fix the issue with my login Form. In my main class, if I do:
theme = UIManager.initFirstTheme("/theme");
instead of
try {
Resources theme = Resources.openLayered("/theme");
UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
} catch (IOException e) {
e.printStackTrace();
}
that works (but I don't understand why as initFirstTheme() is suposed to
be a shorthand notation of the latest...)
However, if I do that, my Login Form (= Sign In) layout is all messed up
again, like in my previous post! (whereas it is OK when I use the second
code with try catch):
<https://lh3.googleusercontent.com/-_K-KJLFN4MU/WrlG9sN-uKI/AAAAAAAAAC0/_rNe9K4osQUBH1zkxroqKqUHgBV9q4Z2QCLcBGAs/s1600/cn1_simulator_issue5.png>
Here is the code of my MainApplication class:
package org.tbdlab.cn1test;
import static com.codename1.ui.CN.addNetworkErrorListener;
import static com.codename1.ui.CN.updateNetworkThreadCount;
import org.tbdlab.cn1test.screens.Launch;
import com.codename1.io.Log;
import com.codename1.ui.Dialog;
import com.codename1.ui.Display;
import com.codename1.ui.Form;
import com.codename1.ui.SideMenuBar;
import com.codename1.ui.Toolbar;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
/**
* This file was generated by <a
href="https://www.codenameone.com/">Codename One</a> for the purpose
* of building native mobile applications using Java.
*/
@SuppressWarnings("deprecation")
public class MyApplication
{
private Form current;
private Resources theme;
private Form home;
public void init(Object context) {
// use two network threads instead of one
updateNetworkThreadCount(2);
theme = UIManager.initFirstTheme("/theme");
/*
try {
Resources theme = Resources.openLayered("/theme");
UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
} catch (IOException e) {
e.printStackTrace();
}
*/
// Enable Toolbar on all Forms by default
Toolbar.setGlobalToolbar(true);
// Pro only feature
//Log.bindCrashProtection(true);
//Side menu
Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_SIDE_NAVIGATION);
UIManager.getInstance().getLookAndFeel().setMenuBarClass(SideMenuBar.class);
addNetworkErrorListener(err -> {
// prevent the event from propagating
err.consume();
if(err.getError() != null) {
Log.e(err.getError());
}
Log.sendLogAsync();
Dialog.show("Connection Error", "There was a networking error
in the connection to " + err.getConnectionRequest().getUrl(), "OK", null);
});
}
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Launch();
hi.show();
}
public void stop() {
current = Display.getInstance().getCurrent();
if(current instanceof Dialog) {
((Dialog)current).dispose();
current = Display.getInstance().getCurrent();
}
}
public void destroy() {
}
}
The one of my Launch Form:
package org.tbdlab.cn1test.screens;
import com.codename1.ui.Form;
public class Launch extends com.codename1.ui.Form {
public Launch() {
this(com.codename1.ui.util.Resources.getGlobalResources());
}
public Launch(com.codename1.ui.util.Resources resourceObjectInstance) {
initGuiBuilderComponents(resourceObjectInstance);
this.getToolbar().hideToolbar();
}
//-- DON'T EDIT BELOW THIS LINE!!!
private com.codename1.ui.Button gui_CreateAccountButton = new
com.codename1.ui.Button();
private com.codename1.ui.Button gui_SignInButton = new
com.codename1.ui.Button();
private com.codename1.components.ScaleImageLabel gui_Logo = new
com.codename1.components.ScaleImageLabel();
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void guiBuilderBindComponentListeners() {
EventCallbackClass callback = new EventCallbackClass();
gui_CreateAccountButton.addActionListener(callback);
gui_SignInButton.addActionListener(callback);
}
class EventCallbackClass implements
com.codename1.ui.events.ActionListener,
com.codename1.ui.events.DataChangedListener {
private com.codename1.ui.Component cmp;
public EventCallbackClass(com.codename1.ui.Component cmp) {
this.cmp = cmp;
}
public EventCallbackClass() {
}
public void actionPerformed(com.codename1.ui.events.ActionEvent ev)
{
com.codename1.ui.Component sourceComponent = ev.getComponent();
if(sourceComponent.getParent().getLeadParent() != null &&
(sourceComponent.getParent().getLeadParent() instanceof
com.codename1.components.MultiButton ||
sourceComponent.getParent().getLeadParent() instanceof
com.codename1.components.SpanButton)) {
sourceComponent =
sourceComponent.getParent().getLeadParent();
}
if(sourceComponent == gui_CreateAccountButton) {
onCreateAccountButtonActionEvent(ev);
}
if(sourceComponent == gui_SignInButton) {
onSignInButtonActionEvent(ev);
}
}
public void dataChanged(int type, int index) {
}
}
private void initGuiBuilderComponents(com.codename1.ui.util.Resources
resourceObjectInstance) {
guiBuilderBindComponentListeners();
setLayout(new com.codename1.ui.layouts.LayeredLayout());
setInlineStylesTheme(resourceObjectInstance);
setScrollableY(false);
setInlineStylesTheme(resourceObjectInstance);
addComponent(gui_CreateAccountButton);
addComponent(gui_SignInButton);
addComponent(gui_Logo);
gui_CreateAccountButton.setText("Create an account");
gui_CreateAccountButton.setInlineStylesTheme(resourceObjectInstance);
gui_CreateAccountButton.setInlineAllStyles("border:round ffbbbbbb
rect; fgColor:ffffff; opacity:255; bgImage:; alignment:center;
padding:2.5mm 2.5mm 2.5mm 2.5mm;");
gui_CreateAccountButton.setName("CreateAccountButton");
gui_CreateAccountButton.setTextPosition(com.codename1.ui.Component.LEFT);
((com.codename1.ui.layouts.LayeredLayout)gui_CreateAccountButton.getParent().getLayout()).setInsets(gui_CreateAccountButton,
"auto 5.0mm 5.0mm 5.0mm").setReferenceComponents(gui_CreateAccountButton,
"-1 -1 -1 -1").setReferencePositions(gui_CreateAccountButton, "0.0 0.0 0.0
0.0");
gui_SignInButton.setText("Sign in");
gui_SignInButton.setInlineStylesTheme(resourceObjectInstance);
gui_SignInButton.setInlineAllStyles("border:round ff5bc8fb rect;
fgColor:ffffff; opacity:255; bgImage:; alignment:center; padding:2.5mm
2.5mm 2.5mm 2.5mm;");
gui_SignInButton.setName("SignInButton");
gui_SignInButton.setTextPosition(com.codename1.ui.Component.LEFT);
((com.codename1.ui.layouts.LayeredLayout)gui_SignInButton.getParent().getLayout()).setInsets(gui_SignInButton,
"auto 5.0mm 3.0mm 5.0mm").setReferenceComponents(gui_SignInButton, "-1 -1 0
-1").setReferencePositions(gui_SignInButton, "0.0 0.0 1.0 0.0");
gui_Logo.setPreferredSizeStr("50.0mm inherit");
gui_Logo.setInlineStylesTheme(resourceObjectInstance);
gui_Logo.setName("Logo");
com.codename1.ui.FontImage.setMaterialIcon(gui_Logo,"\ue3f4".charAt(0));
((com.codename1.ui.layouts.LayeredLayout)gui_Logo.getParent().getLayout()).setInsets(gui_Logo,
"5.0mm auto 5.0mm auto").setReferenceComponents(gui_Logo, "-1 -1 1
-1").setReferencePositions(gui_Logo, "0.0 0.0 1.0 0.0");
}// </editor-fold>
//-- DON'T EDIT ABOVE THIS LINE!!!
public void
onSignInButtonActionEvent(com.codename1.ui.events.ActionEvent ev) {
Form loginf = new Login();
//loginf.getToolbar().setBackCommand("", e -> ((Form)
ev.getComponent().getParent()).showBack());
loginf.show();
}
public void
onCreateAccountButtonActionEvent(com.codename1.ui.events.ActionEvent ev) {
Form signf = new Register();
//signf.getToolbar().setBackCommand("", e -> ((Form)
ev.getComponent().getParent()).showBack());
signf.show();
}
}
and the one of my Login Form:
package org.tbdlab.cn1test.screens;
public class Login extends com.codename1.ui.Form {
public Login() {
this(com.codename1.ui.util.Resources.getGlobalResources());
}
public Login(com.codename1.ui.util.Resources resourceObjectInstance) {
initGuiBuilderComponents(resourceObjectInstance);
}
//-- DON'T EDIT BELOW THIS LINE!!!
private com.codename1.ui.TextField gui_Email = new
com.codename1.ui.TextField();
private com.codename1.ui.TextField gui_Password = new
com.codename1.ui.TextField();
private com.codename1.ui.Button gui_LoginButton = new
com.codename1.ui.Button();
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initGuiBuilderComponents(com.codename1.ui.util.Resources
resourceObjectInstance) {
setLayout(new com.codename1.ui.layouts.LayeredLayout());
setInlineStylesTheme(resourceObjectInstance);
setScrollableY(false);
setInlineStylesTheme(resourceObjectInstance);
setInlineAllStyles("transparency:0; opacity:255;
alignment:center;");
setTitle("Sign In");
setName("Login");
addComponent(gui_Email);
addComponent(gui_Password);
addComponent(gui_LoginButton);
gui_Email.setHint("Email");
gui_Email.setInlineStylesTheme(resourceObjectInstance);
gui_Email.setInlineAllStyles("border:none;");
gui_Email.setName("Email");
gui_Email.setRows(1);
((com.codename1.ui.layouts.LayeredLayout)gui_Email.getParent().getLayout()).setInsets(gui_Email,
"5.0mm 5.0mm auto 5.0mm").setReferenceComponents(gui_Email, "-1 -1 -1
-1").setReferencePositions(gui_Email, "0.0 0.0 0.0 0.0");
gui_Password.setHint("Password");
gui_Password.setInlineStylesTheme(resourceObjectInstance);
gui_Password.setInlineAllStyles("border:none;");
gui_Password.setName("Password");
gui_Password.setRows(1);
((com.codename1.ui.layouts.LayeredLayout)gui_Password.getParent().getLayout()).setInsets(gui_Password,
"5.0mm 0.0mm auto 0.0mm").setReferenceComponents(gui_Password, "0 0 -1 0
").setReferencePositions(gui_Password, "1.0 0.0 0.0 0.0");
gui_LoginButton.setText("Login");
gui_LoginButton.setInlineStylesTheme(resourceObjectInstance);
gui_LoginButton.setName("LoginButton");
((com.codename1.ui.layouts.LayeredLayout)gui_LoginButton.getParent().getLayout()).setInsets(gui_LoginButton,
"10.0mm 5.0mm auto 5.0mm").setReferenceComponents(gui_LoginButton, "1 -1 -1
-1").setReferencePositions(gui_LoginButton, "1.0 0.0 0.0 0.0");
}// </editor-fold>
//-- DON'T EDIT ABOVE THIS LINE!!!
}
On Monday, March 26, 2018 at 1:50:10 PM UTC+2, Steve Hannah wrote:
>
> I just copied the source code you posted directly into a project that uses
> the blue theme, and this was the result in the Simulator.
>
>
>
> I'm not sure why you'd be getting different results. Perhaps your project
> is using an older version of the libs. Make sure that:
>
> 1. Your Codename One plugin is up to date with the latest.
> 2. That your project libs are up to date. (I.e. Project Properties >
> Click "Update project libs".
>
>
> WRT hiding the titlebar altogether, try this:
> https://stackoverflow.com/questions/42871223/how-do-i-hide-get-rid-the-title-bar-on-a-form-codename-one
>
> Steve
>
>
> On Fri, Mar 23, 2018 at 12:36 PM, Thomas <[email protected]
> <javascript:>> wrote:
>
>> The SignInForm UIID was the source of the issue. Thanks. (Not sure why
>> taking a screenshot changed the layout though...)
>> I now have another issue with the simulator.
>>
>> Here is the source code of my class generated with the GUI builder:
>>
>> import com.codename1.ui.Form;
>>
>>
>> public class Launch extends com.codename1.ui.Form {
>> public Launch() {
>> this(com.codename1.ui.util.Resources.getGlobalResources());
>> }
>>
>> public Launch(com.codename1.ui.util.Resources resourceObjectInstance)
>> {
>> initGuiBuilderComponents(resourceObjectInstance);
>> }
>>
>> //-- DON'T EDIT BELOW THIS LINE!!!
>> private com.codename1.ui.Button gui_CreateAccountButton = new
>> com.codename1.ui.Button();
>> private com.codename1.ui.Button gui_SignInButton = new
>> com.codename1.ui.Button();
>> private com.codename1.components.ScaleImageLabel gui_Logo = new
>> com.codename1.components.ScaleImageLabel();
>>
>>
>> // <editor-fold defaultstate="collapsed" desc="Generated Code">
>>
>> private void guiBuilderBindComponentListeners() {
>> EventCallbackClass callback = new EventCallbackClass();
>> gui_CreateAccountButton.addActionListener(callback);
>> gui_SignInButton.addActionListener(callback);
>> }
>>
>> class EventCallbackClass implements
>> com.codename1.ui.events.ActionListener,
>> com.codename1.ui.events.DataChangedListener {
>> private com.codename1.ui.Component cmp;
>> public EventCallbackClass(com.codename1.ui.Component cmp) {
>> this.cmp = cmp;
>> }
>>
>> public EventCallbackClass() {
>> }
>>
>> public void actionPerformed(com.codename1.ui.events.ActionEvent
>> ev) {
>> com.codename1.ui.Component sourceComponent =
>> ev.getComponent();
>>
>> if(sourceComponent.getParent().getLeadParent() != null &&
>> (sourceComponent.getParent().getLeadParent() instanceof
>> com.codename1.components.MultiButton ||
>> sourceComponent.getParent().getLeadParent() instanceof
>> com.codename1.components.SpanButton)) {
>> sourceComponent =
>> sourceComponent.getParent().getLeadParent();
>> }
>>
>> if(sourceComponent == gui_CreateAccountButton) {
>> onCreateAccountButtonActionEvent(ev);
>> }
>> if(sourceComponent == gui_SignInButton) {
>> onSignInButtonActionEvent(ev);
>> }
>> }
>>
>> public void dataChanged(int type, int index) {
>> }
>> }
>> private void initGuiBuilderComponents(com.codename1.ui.util.Resources
>> resourceObjectInstance) {
>> guiBuilderBindComponentListeners();
>> setLayout(new com.codename1.ui.layouts.LayeredLayout());
>> setInlineStylesTheme(resourceObjectInstance);
>> setScrollableY(false);
>> setInlineStylesTheme(resourceObjectInstance);
>> addComponent(gui_CreateAccountButton);
>> addComponent(gui_SignInButton);
>> addComponent(gui_Logo);
>> gui_CreateAccountButton.setText("Create an account");
>>
>> gui_CreateAccountButton.setInlineStylesTheme(resourceObjectInstance);
>> gui_CreateAccountButton.setInlineAllStyles("border:round ffbbbbbb
>> rect; fgColor:ffffff; opacity:255; bgImage:; alignment:center;
>> padding:2.5mm 2.5mm 2.5mm 2.5mm;");
>> gui_CreateAccountButton.setName("CreateAccountButton");
>>
>> gui_CreateAccountButton.setTextPosition(com.codename1.ui.Component.LEFT);
>>
>> ((com.codename1.ui.layouts.LayeredLayout)gui_CreateAccountButton.getParent().getLayout()).setInsets(gui_CreateAccountButton,
>>
>> "auto 5.0mm 5.0mm 5.0mm").setReferenceComponents(gui_CreateAccountButton,
>> "-1 -1 -1 -1").setReferencePositions(gui_CreateAccountButton, "0.0 0.0 0.0
>> 0.0");
>> gui_SignInButton.setText("Sign in");
>>
>> gui_SignInButton.setInlineStylesTheme(resourceObjectInstance);
>> gui_SignInButton.setInlineAllStyles("border:round ff5bc8fb rect;
>> fgColor:ffffff; opacity:255; bgImage:; alignment:center; padding:2.5mm
>> 2.5mm 2.5mm 2.5mm;");
>> gui_SignInButton.setName("SignInButton");
>> gui_SignInButton.setTextPosition(com.codename1.ui.Component.LEFT);
>>
>> ((com.codename1.ui.layouts.LayeredLayout)gui_SignInButton.getParent().getLayout()).setInsets(gui_SignInButton,
>>
>> "auto 5.0mm 3.0mm 5.0mm").setReferenceComponents(gui_SignInButton, "-1 -1 0
>> -1").setReferencePositions(gui_SignInButton, "0.0 0.0 1.0 0.0");
>> gui_Logo.setPreferredSizeStr("50.0mm inherit");
>> gui_Logo.setInlineStylesTheme(resourceObjectInstance);
>> gui_Logo.setName("Logo");
>>
>> com.codename1.ui.FontImage.setMaterialIcon(gui_Logo,"\ue3f4".charAt(0));
>>
>> ((com.codename1.ui.layouts.LayeredLayout)gui_Logo.getParent().getLayout()).setInsets(gui_Logo,
>>
>> "5.0mm auto 5.0mm auto").setReferenceComponents(gui_Logo, "-1 -1 1
>> -1").setReferencePositions(gui_Logo, "0.0 0.0 1.0 0.0");
>> }// </editor-fold>
>>
>> //-- DON'T EDIT ABOVE THIS LINE!!!
>>
>> public void
>> onSignInButtonActionEvent(com.codename1.ui.events.ActionEvent ev) {
>> Form loginf = new Login();
>> //loginf.getToolbar().setBackCommand("", e -> ((Form)
>> ev.getComponent().getParent()).showBack());
>> loginf.show();
>> }
>>
>> public void
>> onCreateAccountButtonActionEvent(com.codename1.ui.events.ActionEvent ev) {
>> Form signf = new Register();
>> //signf.getToolbar().setBackCommand("", e -> ((Form)
>> ev.getComponent().getParent()).showBack());
>> signf.show();
>> }
>>
>>
>> }
>>
>> This is how it (correctly) appears in the GUI builder preview:
>>
>>
>>
>>
>> <https://lh3.googleusercontent.com/-nvAuoPl97Yc/WrVUOeyBXlI/AAAAAAAAAB0/W8RKk3LwLagZKS9fqzFJZtV6iqW9M95qwCLcBGAs/s1600/cn1_simulator_issue3.png>
>>
>>
>> And here is the result in the simulator:
>>
>>
>>
>> <https://lh3.googleusercontent.com/-Fk46h3R6qeU/WrVUfNhqRkI/AAAAAAAAAB4/onllm6BOcmMTibXsr4iQRJ8_bOuxl_1wwCLcBGAs/s1600/cn1_simulator_issue4.png>
>>
>>
>> I really don't undrstand why the simulator do not reflect the specific
>> button properties I set in the GUI builder and keep using the default
>> flatBlue theme button properties. (yet the code produced by the GUI builder
>> seems to correctly override them...)
>> Also how can I completely remove the title component at the top of the
>> form. I don't want any empty blue title bar to appear. I tried to do
>> setTitle(null)
>> setName(null)
>> in my code so as
>> setTitle("")
>> setName("")
>>
>> but with no effect...
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "CodenameOne Discussions" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected]
>> <javascript:>.
>> Visit this group at
>> https://groups.google.com/group/codenameone-discussions.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/codenameone-discussions/dd1973f4-358d-4fab-b642-53a1b8a16ce1%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/codenameone-discussions/dd1973f4-358d-4fab-b642-53a1b8a16ce1%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Steve Hannah
> Software Developer
> Codename One
> http://www.codenameone.com
>
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/1bea8bd1-5d97-4e2e-87c3-d3f9c228169f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.