0

The Java documentation claims that the Menu Bar of a Frame is directly positioned and/or attached to the Content Pane of such frame but when I check the source code of this Java classes -specially the one that belongs to the JFrame, JRootPane and Container- it looks to me that the Menu Bar actually belongs to the JRootPane itself, which I know also contains the Content Pane in question but the Menu Bar still doesn't look to be positioned or attacked to the Content Pane itself but the container object which is the RootPane containing the Content Pane.

I'm still new on this so there's a huge chance that I'm just not getting it right or missing something. Any clarification on whether my assessment is accurate or what is it that I'm confusing would be greatly appreciated.

Here's the link where I found that claim: https://docs.oracle.com/javase/tutorial/uiswing/components/rootpane.html

WagnerR
  • 5
  • 2
  • I would describe it this way: It is positioned (or "attached") directly above (or "north") of the content pane (but below) the top edge of the frame. Attached in the sense that moving one moves the other. Everything else is an implementation detail. – Elliott Frisch Mar 23 '20 at 02:35

1 Answers1

0

The Java documentation claims that the Menu Bar of a Frame is directly positioned and/or attached to the Content Pane

Where does it state that? Don't paraphrase. Post the statement from the tutorial if there is something you don't understand.

but when I check the source code of this Java classes

Why would you check the source code when you are just learning Swing?

it looks to me that the Menu Bar actually belongs to the JRootPane itself,

And that is exactly what the tutorial says. It states:

a root pane has four parts

and goes on to list the content pane and optional menu bar as two of the parts.

I'm not understanding your confusion?

You use:

frame.setJMenuBar(…);
frame.setContentPane(…)

to add the menu bar and content pane to the frame.

camickr
  • 321,443
  • 19
  • 166
  • 288
  • I just read the documentation one more time and I realize what you mean know, I got it all wrong. Perhaps I got confused due to the fact that the image that illustrates this shows them like if that would be the case (and the fact I was tired when read it) but after reading more I noticed it´s just referring to the fact that they're both on the same depth. – WagnerR Mar 23 '20 at 04:53