0

I am kind of new to Java, I tried finding an answer for hours but I couldn't. The problem is pretty simple - I create an array of JButton components, and add them to a JFrame using:

m_Parent.add(this);

And it works.

The problem is, I want the same array to appear in a JInternalFrame I created in the frame. But when I add:

m_Parent.Internal.add(this);

It only shows up in the internal frame, and no longer appears in the frame. Why does this happen? how can I make it appear in both frames?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Nanis
  • 1
  • A component can only have a single parent. So you can't add the same component to two different containers. So you need to create two separate arrays of buttons. – camickr Aug 19 '17 at 19:10
  • As has been asked and answered previously, a Swing component can be added to one and only one container. If you need to add it to multiple, then consider creating a factory method that creates the component that you wish to add to multiple locations. – Hovercraft Full Of Eels Aug 19 '17 at 19:10

0 Answers0