开发者

mig layout - span and grow/push spacing

开发者 https://www.devze.com 2022-12-27 23:12 出处:网络
I want 3 components laid out on 2 lines, so that the bottom component and the top-right component use all available horizontal space.

I want 3 components laid out on 2 lines, so that the bottom component and the top-right component use all available horizontal space.

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setLayout(new MigLayout("debug, fill"));
Contai开发者_开发技巧ner cp = frame.getContentPane();
cp.add(new JTextField("component 1"), "");
cp.add(new JTextField("component 2"), "growx,push,wrap");
cp.add(new JTextField("component 3"), "span,growx,push");
frame.pack();
frame.setVisible(true);

Considering the above, how do i stop the space between "component 1" and "component 2" from appearing when resizing the frame?

mig layout - span and grow/push spacing


cp.add(new JTextField("component 1"), "");
cp.add(new JTextField("component 2"), "growx,push,wrap");
cp.add(new JTextField("component 3"), "span,growx,pushy");

solves this case.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号