小编ama*_*ana的帖子

设置大小不适用于java

public void start_Gui() {

    JFrame window = new JFrame("Client Program");
    window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel();
    window.setContentPane(panel);
    panel.setLayout(new GridLayout(1,2));

    JLabel leftside = new JLabel();
    leftside.setLayout(new GridLayout(2, 1));

    JTextArea rightside = new JTextArea();
    rightside.setEditable(false);   //add scroll pane.
    rightside.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    rightside.setLayout(new FlowLayout());

    JTextArea client_text_input = new JTextArea();
    client_text_input.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    leftside.add(client_text_input);

    JLabel buttons_layer = new JLabel();
    JButton login = new JButton("Login");
    JButton logout = new JButton("Logout");
    buttons_layer.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    buttons_layer.setLayout(new GridLayout(2, 1));
    buttons_layer.add(login);
    buttons_layer.add(logout);
    leftside.add(buttons_layer);

    panel.add(leftside);
    panel.add(rightside);

    window.setSize(300, 400);
    window.setResizable(false);
    window.setVisible(true);
}
Run Code Online (Sandbox Code Playgroud)

我正在研究一个简单的Java聊天客户端gui应用程序.(服务器等,由其他人完成).

这不是一个大项目,但我唯一的问题是,无论我尝试调整上述GUI上的任何组件的大小,都行不通.

例如:

JTextArea …
Run Code Online (Sandbox Code Playgroud)

java swing

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×1

swing ×1