java setsize没有作用_设置大小在Java中不起作用

博主在创建一个简单的Java聊天客户端GUI时遇到组件大小调整无效的问题。代码中展示了窗口、面板、组件的设置,包括JFrame、JPanel、JTextArea、JButton等,但尝试设置JTextArea的大小无效。
摘要由CSDN通过智能技术生成

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);

}

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

这不是一个大项目,但是我唯一的问题是,无论如何尝试调整上述GUI上任何组件的大小,都将无法正常工作。

例如:

JTextArea client_text_input = new JTextArea();

client_text_input.setSize(100,200);

不行

谢谢您的帮助。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值