I have main window in my program - class that inherit JFrame, this window have JMenuBar.
In code I dynamically create instance of JPanel with some components and set this panel to main window as 开发者_运维技巧content pane.
But after this menu bar intersects with my panel, the part of panel is behind menu bar. This continues until I change my window size.
After this intersection disappears, and menu panel placed under menu bar without intersect.
JFrame view = ApplicationContext.getInstance().getView();
JPanel panel = new TherapeuticProfile().getRootPanel();
view.setContentPane(panel);
Doing this after the window is displayed? In which case you will need revalidate
.
Doing this off the AWT EDT? In which case you'll need to stop doing that.
(Also statics, as in ApplicationContext.getInstance()
are a really bad idea in any program.)
精彩评论