This seems like a very beginner question, but I don't know the answer.
Suppose you create a new JFrame in Java. With the new frame comes the default content pane. If I declare a variable and initialize it as that frame's content pane, is the variable I initialized a reference to the frame's content pane or does it become its own thing? Example:
JFrame frame = new JFrame();
Container panel = frame.getContentPane();
If I wanted to, for example, change the layout of the content pane, would adjusting panel
give the same effect as changing frame.getContentPane()
?
To show exactly what I mean:
frame.getContentPane().setLayout(new GridLayout());
Would this create the same result as:
panel.setLayout(new GridLayout());
Will anything that I then do to panel
then be reflected in frame
without me having to then say frame.setContentPane(panel);
at the end?