problems in laying out panels
Hi all,
I'm experiencing a strange problem in laying out panels in my JFrame. This is the situation: JFrame has the borderlayout, the north is assinged to a JToolBar, the center is assigned to another JSplitPane, and the south is assigned to another JPanel. Nothing is placed at the east and west sides. The problem is that
1) the center is not using all the size of the window and remains littler than the whole window. Moreover, it seems to be cut depending on the screen resolution: sometimes the bottom part of the JSplitPane is not shown on the window, and sometimes the horizontal right part is cut on screens with a different resolution of mine. I didn't set the size (preferred, min, max) of the any panel.
The following is the part of code that builds up the JFrame layout:
publicvoid initGUI(){
// sets the layout
this.setLayout(new BorderLayout() );
// builds up the menu bar
JMenu databaseMenu =new JMenu("Database");
this.connectToDatabaseMenuItem = ComponentBuilder.createJMenuItem("Connetti al server database",CommandStrings.CONNECT,this);
JMenuItem exit = ComponentBuilder.createJMenuItem("Esci",CommandStrings.EXIT,this);
databaseMenu.add(this.connectToDatabaseMenuItem);
databaseMenu.addSeparator();
databaseMenu.add(exit);
JMenu actionMenu =new JMenu("Azioni");
JMenuBar bar =new JMenuBar();
bar.add(databaseMenu);
bar.add(actionMenu);
JMenu toolsMenu =new JMenu("Strumenti");
JMenuItem runGC = ComponentBuilder.createJMenuItem("Pulizia memoria", CommandStrings.RUN_GC,this);
toolsMenu.add(runGC);
JMenu helpMenu =new JMenu("Help");
JMenuItem credits = ComponentBuilder.createJMenuItem("Credits", CommandStrings.CREDITS,this);
helpMenu.add(credits);
bar.add(helpMenu);
bar.add(toolsMenu);
this.setJMenuBar(bar);
// builds up the toolbar
JToolBar toolBar =new JToolBar();
toolBar.setLayout(new BoxLayout(toolBar,BoxLayout.LINE_AXIS));
this.connectToDatabaseButton = ComponentBuilder.createJButton("Connetti",CommandStrings.CONNECT,this);
toolBar.add(this.connectToDatabaseButton);
toolBar.add(Box.createHorizontalGlue());// fill the space so that the logo appears on the right side of
// toolbar. The glue is invisible
toolBar.addSeparator();
toolBar.add(new ImagePanel(ComponentBuilder.getPoweredLogoPath()));
this.add(toolBar,BorderLayout.NORTH);
// add the status/memory bar at the bottom
this.statusBar = MainFrameStatusBar.getInstance();
this.statusBar.setText("Ready");
this.add( this.statusBar, BorderLayout.SOUTH);
//add the main panel at the center
this.mainPanel =new MainPanel(this,actionMenu);
this.add(mainPanel, BorderLayout.CENTER);
this.add(mainPanel);
// all done
this.centerIntoScreen(0.9);
}
Any idea about how to force the center panel to adapt itself to the rest of the window size?
Thanks,
Luca

