Reputation: 746
I am trying to create a class, which extends JFrame and uses GroupLayout, but i cant find on how to do that. It's very simple for a JPanel:
GroupLayout layout=new GroupLayout(this);
setLayout(layout);
But if if I'm using JFrame, it says that I'm adding two containers for the frame on line two, but without the line, the layout isn't added, shows the last added component. Tried googling, no luck. Thanks!
Upvotes: 0
Views: 598
Reputation: 159754
For the GroupLayout
host container, you need to use the container where all the visible components will be added to the the JFrame
. This is the ContentPane
:
JFrame frame = new JFrame();
GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
frame.setLayout(groupLayout);
Upvotes: 2