J-component具有setBounds
功能,与parent frame的左上角相比,它使您可以固定组件。
/**
* Moves and resizes this component. The new location of the top-left
* corner is specified by <code>x</code> and <code>y</code>, and the
* new size is specified by <code>width</code> and <code>height</code>.
* <p>
* This method changes layout-related information, and therefore,
* invalidates the component hierarchy.
*
* @param x the new <i>x</i>-coordinate of this component
* @param y the new <i>y</i>-coordinate of this component
* @param width the new <code>width</code> of this component
* @param height the new <code>height</code> of this
* component
* @see #getBounds
* @see #setLocation(int, int)
* @see #setLocation(Point)
* @see #setSize(int, int)
* @see #setSize(Dimension)
* @see #invalidate
* @since JDK1.1
*/
public void setBounds(int x, int y, int width, int height) {
reshape(x, y, width, height);
}
我希望这会有所帮助。