Set the JPanel size to fill parent with little margin

后端 未结 4 802
遇见更好的自我
遇见更好的自我 2021-01-07 10:15

I have two Jpanel (JpanelLeft and JpanelLeftContent) how can i make the JpanelLeftContent fill parent size with a little margin on the lef

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-07 10:29

    To make a JPanel appear rounded, you need to make your own class that extends JPanel, override paintComponent and draw the panel as an ellipse Javadoc here This will create a customized object which is an JPanel.

    When you specify the size of your ellipse, you want to get the Y and X values from the parent panel (since you will be adding your ellipse ontop of another panel) and then subtract the number of pixels you desire from the X-axis. This could be achived by passing those values to the "ellipse panel" constructor.

提交回复
热议问题