I want to programmatically move my JLabel to a specific location inside my JPanel. I have tried setLocation(int x, int y)
, but it doesn't work.
I am trying to not use any layout manager.
13297 次
1 に答える
12
これは、レイアウト マネージャーを使用せずにコンポーネントをレイアウトする方法に関する優れたチュートリアルです。
http://java.sun.com/docs/books/tutorial/uiswing/layout/none.html
レイアウト マネージャーを使用せずにコンテナーを作成するには、次の手順を実行します。
- を呼び出して、コンテナーのレイアウト マネージャーを null に設定します
setLayout(null)
。setbounds
コンテナの各子に対してComponent クラスのメソッドを呼び出します。- Component クラスの
repaint
メソッドを呼び出します。
于 2010-06-21T13:50:11.813 に答える