I have a JFrame
window to which I am trying to add 3 panels. One panel is for input (text areas and their labels which I already have arranged within the panel), one is for a set of buttons, and one is for output. I want the the input and button panels to share the left half of the window (input panel on top and button panel below) and the output panel to take up the entire right half of the window by itself. Because of this, GridLayout
, BoxLayout
, and BorderLayout
don't work by themselves. I just tried making one container and adding the input and button panels to it with the input panel above and the button panel below. I then made a second container and tried adding the first container to it on the left side and the output panel to the right side. The compiler told me I can't add a container's parent to itself. How can I make two panels share the left side and have a third have the right side to itself?
Recommended Answers
Jump to Postmaybe typos mistake,check that again because one cotainer you can add just one, that standard how to lay GUI, nice way
hmmm these "panels" are declared (at all) as JPanels ???,
Jump to PostleftSide is the contentpane for the window (previous listing line 5)
bothSides is also the contentpane for the window (previous listing line 14)
so on line 17 you are trying to add the content pane to itself, == error.At a guess, leftSide should be a new container.
Jump to PostI made leftSide a container and that worked. I didn't realize that I hadn't done that in the first place. Thank you very much.
OK, glad to help. Mark this solved?
All 10 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.