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.
Asked
Active
Viewed 1.3k times
7
-
3Post that edit as an answer and I'll upvote it. Figuring out the answer on your own is a good thing and should be rewarded. :) – Michael Myers May 12 '10 at 16:52
-
+1 For updating the question. @oletus: Consider adding an answer with a simple example. http://sscce.org/ – trashgod May 12 '10 at 19:17
-
-1 for updating the question instead of answering his own question. – shemnon May 16 '10 at 02:33
1 Answers
12
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.
- Set the container's layout manager to null by calling
setLayout(null)
.- Call the Component class's
setbounds
method for each of the container's children.- Call the Component class's
repaint
method.
![](../../users/profiles/2598.webp)
jjnguy
- 128,890
- 51
- 289
- 321