FrameView doesn't show new JPanel until I resize
My Java swing GUI doesn't repaint until I resize the window. I create a FrameView with a menuBar (with menu items whose events cause the loading of different JPanels via FrameView's setComponent) and a dummy/empty JPanel. When user selects a menu item, a custom JPanel is created and FrameView's setComponent is called with this as a parameter. When I run it and select the menu item, I don't see the new JPanel being loaded -- until I manually resize the window. Any help? Following is the code snippet:
Code:
public class MyDesktopApp extends SingleFrameApplication
{
@Override protected void startup() { show(new MyDesktopView(this)); }
}
public class MyDesktopView extends FrameView {
public MyDesktopView (SingleFrameApplication app) {
mainPanel = new JPanel();
mainMenu = new JMenu();
importMenu = new JMenu();
menuBar = new JMenuBar();
importMyFileMenuItem = new JMenuItem();
importMyFileMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
importMyFileMenuItemActionPerformed(evt);
}
});
importMenu .add(importMyFileMenuItem );
mainMenu.add(importMenu);
menuBar.add(mainMenu);
setMenuBar(menuBar);
setComponent(mainPanel);
}
private void importMyFileMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
ImportMyFileJPanel importMyFileJPanel = new ImportMyFileJPanel ();
setComponent(importMyFileJPanel );
importMyFileJPanel .setVisible(true);
}
}
public class ImportBOIJPanel extends JPanel {
public ImportBOIJPanel() {
// add swing components
}
}
Re: FrameView doesn't show new JPanel until I resize
Hi
I hope it is not too late
try to do that
getApplication().show(this);
after
setComponent(mainPanel);
It forces to redraw the UI
Re: FrameView doesn't show new JPanel until I resize
Quote:
Originally Posted by
mabusto
I hope it is not too late
This thread is almost a year old...