Carlos R
Carlos R

Reputation: 51

trouble with Theme in the olderGUI

i´m starting with CN1, and i traying with Todo App example. When i run de app in Netbeans, only appears a blank form, I changed the themes, I added a jpg image and made others changes in the res file with the olderGUI Builder and use the function theme = UIManager.initNamedTheme("/theme","Theme 2");, but i don´t have any change in the dorm when i try to simulate in Netbeans. This is the complete code in the TodoApp java file, I comment the part of the new hi Form (I use the "Hi World" bare bones template):

public class TodoApp {

    private Form current;
    private Resources theme;

    public void init(Object context) {
        // use two network threads instead of one
        updateNetworkThreadCount(2);

        //theme = UIManager.initFirstTheme("/theme");
        theme = UIManager.initNamedTheme("/theme","Theme 2");

        // Enable Toolbar on all Forms by default
        Toolbar.setGlobalToolbar(true);

        // Pro only feature
        Log.bindCrashProtection(true);

        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 Form("Hi World", BoxLayout.y());
        //hi.add(new Label("Hi World"));
        //hi.show();
        new TodoForm();
       
    }

    public void stop() {
        current = getCurrentForm();
        if(current instanceof Dialog) {
            ((Dialog)current).dispose();
            current = getCurrentForm();
        }
    }
    
    public void destroy() {
    }

}

I couldn't find what i do wrong. Thanks!!!

P.D. Sorry for my English, I learning it too.

Upvotes: 3

Views: 36

Answers (1)

Shai Almog
Shai Almog

Reputation: 52770

We recommend avoiding the old GUI builder. It's no longer supported and wasn't designed for modern mobile apps. In order to use it you have to create a special type of project (old GUI project) and only that type of project works with it.

The new GUI builder works better, it has a more powerful layout system and works in a way that's more consistent with modern GUI builders. See https://www.codenameone.com/blog/tutorial-gui-builder-autolayout-signin-form-responsive.html

Upvotes: 1

Related Questions