与setBounds()混淆的FlowLayout [英] FlowLayout in conjection with setBounds()

查看:114
本文介绍了与setBounds()混淆的FlowLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JFrame.我使用setBounds()确定位置和大小,但是当我使用frame.setLayout( new FlowLayout() )时,所有组件都很混乱.

I have a JFrame. I use setBounds() for determine position and size, but when I use frame.setLayout( new FlowLayout() ) all components are cluttered.

解决方案是什么?

推荐答案

1)setBounds()是错误的做法,其值为LayoutManager(setLayout(null))为空.

1) setBounds() is bad practice with null LayoutManager(setLayout(null)).

2)使用FlowLayout时,它将计算组件的位置和大小.

2) When you use FlowLayout, it calculates positions and sizes of components.

因此,您不能混合使用两种方法.检查如何使用 LayoutManager .

So, you can't mixing 2 approaches. Examine how to use LayoutManager.

这篇关于与setBounds()混淆的FlowLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆