Trouble using ViewPortPanel2D for making a Scroll Box

Hello, I am trying to make a scroll box container for my Lemur GUIs by using the ViewPortPanel2D class, but I am running into a problem where the ViewPortPanel2D automatically resizes itself whenever the game is minimized - but only when using a SpringGridLayout with FillMode.None on both the X and Y axis - which is necissary in order to make sure the scroll box items always appear with the PreferredSize value that i set.

I created a simple test case that adds 3 rows to a ViewPortPanel2D, and I also attached a .gif that shows the way that the rows resize whenever the game is minimized and regains focus.

Here Is my Code:

import com.jme3.app.SimpleApplication;
import com.jme3.math.Vector3f;

import com.jme3.renderer.RenderManager;
import com.jme3.system.AppSettings;
import com.jme3.util.BufferUtils;
import com.nx.util.jme3.lemur.panel.ViewportPanel2D;
import com.simsilica.lemur.Axis;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.FillMode;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.Insets3f;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.component.SpringGridLayout;
import com.simsilica.lemur.style.BaseStyles;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

public class Main extends SimpleApplication {
    
    
    
    
  private static float width, height ;
  private static GraphicsDevice device;
  

    public static void main(String[] args) {
        Main app = new Main();
        
        app.setShowSettings(false);
        app.setDisplayStatView(false);
        app.setDisplayFps(false);
    
        device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        width = device.getDisplayMode().getWidth() * .99f;
        height = device.getDisplayMode().getHeight() * .925f;


    AppSettings settings = new AppSettings(true);

    settings.put("Title", "Afflicted Scene Designer");

    settings.put("FrameRate", 140);
    settings.put("GammaCorrection", true);
    settings.put("Samples", 16);


    settings.put("Width", ((int)width));
    settings.put("Height", ((int)height));

    app.setSettings(settings);


    BufferUtils.setTrackDirectMemoryEnabled(true);
    
    app.start();
}

    

@Override
public void simpleInitApp() {
    
     GuiGlobals.initialize(this);
     BaseStyles.loadGlassStyle();  
     GuiGlobals.getInstance().getStyles().setDefaultStyle("glass");
    
    Container windowContainer = new Container();
    
    windowContainer.setPreferredSize(new Vector3f(500, 500, 1f));
    
    windowContainer.setLayout(new SpringGridLayout(Axis.X, Axis.Y, FillMode.None, FillMode.None));
    
    guiNode.attachChild(windowContainer);
    windowContainer.move(new Vector3f(width * 0.2f, height * 0.8f, 0));
    
    
 
    ViewportPanel2D scrollviewPort = new ViewportPanel2D(getStateManager(), windowContainer.getElementId(), "glass");
    
    Container containerOnViewport = new Container();
    
    
   
    
     scrollviewPort = new ViewportPanel2D(getStateManager(), containerOnViewport.getElementId(), "glass");
      
     
    
    windowContainer.addChild(scrollviewPort);
      
    scrollviewPort.attachScene(containerOnViewport);
      
    containerOnViewport.addChild(getRowContainer(), 0, 0);
    
    containerOnViewport.addChild(getRowContainer(), 1, 0);
    containerOnViewport.addChild(getRowContainer(), 2, 0);

  
     scrollviewPort.setPreferredSize(new Vector3f(500, 220, 1));
     containerOnViewport.setPreferredSize(new Vector3f(400, 220, 1));
    
     
     setPauseOnLostFocus(false);
}

 private Container getRowContainer(){
    Container rowContainer = new Container();
   
    
    rowContainer.setBackground(new QuadBackgroundComponent());
    
    rowContainer.addChild(new Label(" ROW "), 0, 0);
    
    rowContainer.setInsets(new Insets3f(2,2,2,2));
    
    rowContainer.setPreferredSize(new Vector3f(80, 30, 1));
    
    return rowContainer;
}

@Override
public void simpleUpdate(float tpf) {

}

@Override
public void simpleRender(RenderManager rm) {
    
}
}

And here is the results when the game is minimzied and restored and the contents of the ViewPortPanel2D are scaled down.


Any pointers as to what I need to do to get my Containers on the alternate viewport to always be the size i set using .setPreferredSize() would be greatly appreciated.

I am also fairly new to Lemur, as I had started using JME with Nifty, so any advice or tips on how I could improve my Lemur code is also appreciated :smiley:

I typically like to use the default SpringGridLayout for auto-sizing my static interfaces that never change at run-time, and then I like to use the SpringGridLayout with FillMode.None for containers that have a pre-set PreferredSize when I am making an interface that can be added to / removed from dynamically at run time (such as the scroll box that I am having trouble making with the ViewPortPanel2D).

Thanks in advance for any help :slightly_smiling_face: