public class PLogin extends JPanel {
private JButton loginButton;
private JLabel usernameLabel;
private JTextField loginField;
private JLabel passwordLabel;
private JPasswordField passwordField;
private JScrollPane scroller;
private JTextArea status;
public PLogin()
{
loginButton = new JButton("Login");
add(usernameLabel = new JLabel("Username"));
add(loginField = new JTextField(20));
add(passwordLabel = new JLabel("Password "));
add(passwordField = new JPasswordField(20));
add(loginButton, BorderLayout.CENTER);
status = new JTextArea(null, "Waiting", 5, 15);
status.setEditable(false);
scroller = new JScrollPane(status);
scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
add(scroller, BorderLayout.PAGE_END);
}
这是我的登录GUI窗格的代码。
由于某种原因,滚动条和登录按钮彼此相邻。
Username : UsernameField
Password: PasswordField
Login Scroller
我宁愿拥有
Login
Scroller
我已尝试使用BorderLayout.CENTER
和BorderLayout.SOUTH
- 任何想法?