Placing a JLabel at a specific x,y coordinate on a JPanel

前端 未结 6 662
梦毁少年i
梦毁少年i 2020-12-05 16:12

I\'m trying to place a series of JLabels at specific X and Y coordinates on a JPanel (and set its height and width, too). No matter what I do, each label winds up immediatel

6条回答
  •  猫巷女王i
    2020-12-05 16:38

    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.

    Note:

    Creating containers with absolutely positioned containers can cause problems if the window containing the container is resized.

    Refer this link: http://docs.oracle.com/javase/tutorial/uiswing/layout/none.html

提交回复
热议问题