How to add multiple components to a JFrame?

后端 未结 5 1798
遥遥无期
遥遥无期 2020-11-29 13:07

I have a JFrame.

I also have a Box class which extends Component. This box class has a paint method which

5条回答
  •  野性不改
    2020-11-29 13:52

    Thank you for all your answers.

    Since I am using my own custom class, Box, I have the ability of setting the position of my the rectangle through the paint method.

    I realized my Box class was extending the wrong thing. It should have been extending javax.swing.Jcomponent.

    If I now use a panel with an OverlayLayout, add my components to that panel, they all show up properly.

提交回复
热议问题