Manually position JComponent inside JPanel

后端 未结 1 1625
一个人的身影
一个人的身影 2021-01-18 04:40

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

相关标签:
1条回答
  • 2021-01-18 05:23

    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. 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.
    0 讨论(0)
提交回复
热议问题