Why are my items not showing up in JFrame?

后端 未结 6 1071
日久生厌
日久生厌 2020-11-29 10:39

I\'m fairly new to JFrame and I want to know why my items are not showing up on the window. I know i dont have a ActionHandler but I just want my textfield\'s to show up on

6条回答
  •  一生所求
    2020-11-29 11:29

    The default layout manager for JFrame is BorderLayout.

    This means that your components are essentially all been added ontop of each other.

    Try changing the layout manager to something like FlowLayout (for example)...

    enter image description here

    Take a look at A Visual Guide to Layout Managers and Using Layout Managers for more details.

    Also, avoid setSize where possible, use Window#pack instead

    Update

    I'd also like to introduce you to Initial Threads which should be used to launch your UI code...

提交回复
热议问题