http://blog.csdn.net/gcangle/article/details/8222005
————————————————————————————————————————————————————————
In doing an embedded camera project, encountered such a depressed problem.
A new class inherits JPanel, adds some controls to it, joins it in the original JFrame, and then jpanel the controls in anyway.
(For ease of control the ContentPane layout is "BorderLayout", while the JPanel layout is "absolute", JPanel is placed in the North position of Contenpane)
Then the internet to check a lot of information, but still can't solve. can only explore themselves.
After a day of trying, a strange phenomenon was discovered.
When you inherit the layout of the class
Getcontentpane (). Add (comp, borderlayout.center);
The time. The control of this class can actually be displayed properly. While others such as Getcontentpane (). Add (comp, Borderlayout.north), the control cannot be displayed.
It's a magical existence!
So further exploration finally found the core of the problem! Sum up on a sentence
When you write the JPanel layout is null, can only be placed in the center position, otherwise it will not be displayed!
Or, as long as you change the layout to non-null, everything is fine.
——————————————————————————————————————————————————————————————
You should also pay attention to this situation in topcomponent ...
Java:jpanel control cannot display the problem