setBounds
public void setBounds(int x,
int y,
int width,
int height)移動組件並調整其大小。由 x 和 y 指定左上角的新位置,由 width 和 height 指定新的大小。
參數:
x - 組件的新 x 坐標
y - 組件的新 y 坐標
width - 組件的新 width
height - 組件的新 height
button.setBonds(button.getBonds().getX(),button.getBonds().getY()-50,button.getBonds().getWidth
(),button.getBonds().getHeight() )
button.getBonds().getY()-50, 就是向上移動坐標的關鍵