- 区别:
- setSize(int width, int height)
- setLocation(int x, int y)
- setBounds(int x, int y, int width, int height)
- 联系:
设置整个容器的大小,定义控件的大小
setLocation(int x, int y)有两个参数:分别对应宽度和高度。
将组件移到新位置,用x和y参数来指定新位置的左上角
setBounds(int x, int y, int width, int height)对组件进行自定义大小和位置设置,既定义组件的位置,也定义控件的大小,setSize和setLocation两个函数的功能的组合
联系:有四个参数:
- 第一个参数改组件在JFrame中的x坐边;
- 第二个参数改组件在JFrame中的y坐标;
- 第三个参数改组件在JFrame中的组件宽度;
- 第四个参数改组件在JFrame中的组件高度。
setSize(int width, int height)和setLocation(int x, int y)是通过调用setBounds(int x, int y, int width, int height)实现的。



