[SOLVED] MigLayout wrap


#1

@zissis
Can’t seem to make this wrap if I don’t use a Layout constraint in the constructor.

Noramly I use a Layout constraint but I was testing something and ran into this.

Seems there is something wrong here or am I doing something wrong?

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.renderer.RenderManager;
import com.jme3.system.AppSettings;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.Panel;
import com.simsilica.lemur.TextField;
import com.simsilica.lemur.style.BaseStyles;

public class Main extends SimpleApplication {

    public static void main(String[] args) {
        Main app = new Main();
        AppSettings settings = new AppSettings(true);
        settings.setTitle("Wrap Test");
        app.setSettings(settings);
        app.start();
    }

    @Override
    public void simpleInitApp() {
        GuiGlobals.initialize(this);
        BaseStyles.loadGlassStyle();
        GuiGlobals.getInstance().getStyles().setDefaultStyle("glass");

        Container cont = new Container(new MigLayout(null));
        cont.addChild(new Label("Wrap Test"));
        
        TextField fieldNoWrap = cont.addChild(new TextField("I like to wrap, it's my job!."), "wrap");
        fieldNoWrap.setSingleLine(true);
        fieldNoWrap.setPreferredWidth(200);
        
        cont.addChild(new Label("Just A Label"));
        
        TextField fieldGiveItAnotherTry = cont.addChild(new TextField("Wrappings fun, lets all do it!."), "wrap");
        fieldGiveItAnotherTry.setSingleLine(true);
        fieldGiveItAnotherTry.setPreferredWidth(200);
        
        cont.addChild(new Label("Watch this====>"));  
        cont.addChild(new Label("I would normaly wrap but I don't feel like it.", "wrap"));
        cont.addChild(new Label("He didn't wrap so I will just stay here."));
        centerComp(cont);
        guiNode.attachChild(cont);
    }
    
    /**
     * Centers any lemur component to the middle of the screen.
     * 
     * @param cont the lemur component to center.
     */
    public void centerComp(Panel cont) {
        // Position the panel                                                            
        cont.setLocalTranslation((getCamera().getWidth() - cont.getPreferredSize().x)/2, 
                (getCamera().getHeight() + cont.getPreferredSize().y)/2, 0);
    }

    @Override
    public void simpleUpdate(float tpf) {
        //TODO: add update code
    }

    @Override
    public void simpleRender(RenderManager rm) {
        //TODO: add render code
    }
}

#2

Never mind.

Not that the “wrap” is not where its suposed to be…

cont.addChild(new Label("I would normaly wrap but I don't feel like it."), "wrap");

Staying up to late. Dumbass.

Edit: Lemur accepted it as a style argument as it should. Blagh.


#3

I was about to type this response but you where faster :slight_smile: