【发布时间】:2016-08-26 10:01:16
【问题描述】:
我正在尝试为我的登录对话框构建状态栏,但标签未与状态面板的左侧对齐。这是我的代码。
public class LoginDialog extends JDialog {
private static final long serialVersionUID = 1L;
protected JLabel lblTopSpace = null;
protected JPanel loginPanel = null;
protected JPanel statusPanel = null;
public LoginDialog(String title) {
super((Dialog)null);
this.setTitle(title);
Initialize();
}
protected void Initialize() {
lblTopSpace = new JLabel("Login into Bookyard");
lblTopSpace.setForeground(this.getBackground());
loginPanel = new LoginPanel();
statusPanel = new JPanel();
statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
statusPanel.setSize(this.getWidth(), 50);
JLabel lblStatus = new JLabel("Status");
lblStatus.setFont(new Font("Verdana", Font.PLAIN, 12));
lblStatus.setHorizontalAlignment(SwingConstants.LEFT);
statusPanel.add(lblStatus);
this.setLayout(new BorderLayout());
Container container = this.getContentPane();
container.add(lblTopSpace, BorderLayout.NORTH);
container.add(loginPanel, BorderLayout.CENTER);
container.add(statusPanel, BorderLayout.SOUTH);
this.pack();
}
}
这是目前的样子。
我错过了什么?
【问题讨论】:
标签: java swing jpanel jlabel layout-manager