我想在flowlayout中对齐组件。这可能吗? 这是我的代码:
JPanel ppanel = new JPanel(new FlowLayout());
ppanel.add(text);
ppanel.add(btnLogin);
ppanel.add(btnRegister);
text.setAlignmentX(LEFT_ALIGNMENT);
btnLogin.setAlignmentX(RIGHT_ALIGNMENT);
btnRegister.setAlignmentX(RIGHT_ALIGNMENT);
我想将标签“欢迎”移到最左边,将2个按钮移到最右边 有什么建议吗?
答案 0 :(得分:1)
yourpanel.setLayout(new BorderLayout());
yorpanelpanel.add(yourbutton,BorderLayout.WEST);
yorpanelpanel.add(yourbutton,BorderLayout.EAST);
你可能想尝试这段代码,