Reputation: 85
I'm trying to port my Swing program onto my laptop so I can develop, but I suppose the way I've written my component sizes makes it difficult for this to scale.
I decided to set the screen size using the Toolkit.getScreenSize
method and derive the width/height integers to make a multipiler for the sizes, like so:
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int width = screenSize.width;
int height = screenSize.height;
System.out.println(screenSize);
setSize(screenSize);
int matrixWidthModifier = (int) (width*.351523);
int matrixHeightModifer = (int) (height*0.625);
gamePanel.add(boardMatrixPanel, "wrap, align center, w "+ matrixWidthModifier+"!, h "+matrixHeightModifer+"!");
This doesn't produce my intended screen which looks something like this:
Instead, I get this:
However, I am using .setPreferredSize
on a few components, but I'm not sure that they'd heavily impact the screen size. Is there a better way to do what I'm trying to do with MigLayout
?
Upvotes: 0
Views: 52