开发者

Java:How to align JPanels

开发者 https://www.devze.com 2023-01-01 08:10 出处:网络
开发者_如何学JAVAI have this code but it doesn\'t work: jPanel1.add(jLabel1); jPanel2.add(jButton1);

开发者_如何学JAVAI have this code but it doesn't work:

jPanel1.add(jLabel1);
jPanel2.add(jButton1);
jPanel2.add(jButton2);
jPanel3.add(jPanel1,jPanel1.TOP_ALIGNMENT);
jPanel3.add(jPanel2,jPanel2.BOTTOM_ALIGNMENT);
setContentPane(jPanel3);

pack();

Please tell me why!


You're not setting a LayoutManager on any of the panels. This tutorial may be of use to you

0

精彩评论

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