且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在JPanel中手动定位JComponent

更新时间:2023-12-05 08:38:52

这是一个很棒的教程,介绍如何在不使用布局管理器的情况下对组件进行布局.

Here is a great tutorial on how to layout your components without using a layout manager.

http://java.sun.com/docs/books/tutorial/uiswing/layout/none.html

在没有布局管理器的情况下创建容器涉及以下步骤.

Creating a container without a layout manager involves the following steps.

  1. 通过调用 setLayout(null)将容器的布局管理器设置为null.
  2. 为容器的每个子级调用Component类的 setbounds 方法.
  3. 调用Component类的 repaint 方法.
  1. Set the container's layout manager to null by calling setLayout(null).
  2. Call the Component class's setbounds method for each of the container's children.
  3. Call the Component class's repaint method.