I'm building a gui using a jframe as the base window and adding jpanel's to the frame using a gridbaglayout manager. The gridbaglayout is a single column with 5 rows; a jlabel with image and four jpanel's.The first jpanel is a nested panel with 2 borderlayout panels each with 2 flowlayout panels. My problem is the last panel is not visible when i run the application. If i resize the window the panel is there. I've tried adjusting the jframe height, row & column weights in the gridbagconstraints & removing/repositioning panels. If i remove or reposition the jlabel w/image then only the first two jpanels are visible; the same happens if i remove or reposition any of the other jpanels.
Can someone provide some assistance! Any help would be greatly appreciated. Following is some of my code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import javax.swing.JPanel;
public class RequestWindow extends JFrame {
private JPanel jContentPane = null;
/**
* This is the default constructor
*/
public RequestWindow() {
super();
initialize();
}
public static void main(
String[] args) {
RequestWindow rw = new RequestWindow();
rw.setTitle("Request Window");
rw.pack();
rw.setVisible(true);
}
private void initialize() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(ClassNotFoundException cnfe) {
}
catch (IllegalAccessException ilae) {
}
catch (UnsupportedLookAndFeelException ulfe) {
}
catch (InstantiationException ie) {
}
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setContentPane(getJContentPane());
}
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.NORTH;
JLabel ip = new JLabel(new ImageIcon("c:\\HeaderImage.jpg"));
jContentPane.add(ip,c);
c.gridy = GridBagConstraints.RELATIVE;
c.anchor = GridBagConstraints.CENTER;
c.gridheight = GridBagConstraints.RELATIVE;
jContentPane.add(getRequestPanel(),c);
jContentPane.add(getFieldSelectPanel(),c);
jContentPane.add(getRequestFilePathPanel(),c);
}
return jContentPane;
}
}