I want to know can we have a JPanel with a Layout other than its Parent JFrame. For example. If I have JFrame with Border Layout and we have a JPanel embedded on it and it is having different Layout. Is it possible ?
I am trying to do it. But this way the components of that JPanel are not showing.
Here comes the problem in detail :
I have a JFrame and layout for it is Border Layout. I am adding a JPanel on this frame. If I donot set any Layout for the JPanel. All components of JPanel are displaying on the window but When I am setting Grid Layout for JPanel, Components of JPanel are not visible. I am adding Layout to JPanel so as to align the Components. Below is my code :
I have a main class, a frame class and Jpanel class.
    public class AppMain {
    public static void main(String[] args) {
        AppPage1 page1 = new AppPage1("test");
        page1.setVisible(true);
    }
}
public class AppPage1 extends JFrame {
    public AppPage1(String title) throws HeadlessException {
        super(title);
        this.setLayout(new BorderLayout());
        addWindowListener(new WindowAdapter() {
            public void windowOpened(WindowEvent e) {
                setExtendedState(MAXIMIZED_BOTH);
            }
        });
        //Panel for logo
        JLabel testLogo = new JLabel("");
        testLogo.setIcon(new javax.swing.ImageIcon("test.JPG"));
        List<JComponent> componentList = new ArrayList<JComponent>();
        componentList.add(testLogo);
        PagePanel logoPanel = new PagePanel(componentList,null);
        this.add(logoPanel, BorderLayout.NORTH);
        //Panel for Button and checkboxes
        JLabel panelTitle = new JLabel("test Wizard");
        JRadioButton rdButton_ExistingConfigurationFile = new JRadioButton("Existing Configuration File");
        JRadioButton rdButton_ConfigureNewPropertyFile = new JRadioButton("Configure new Property File");
        componentList = new ArrayList<JComponent>();
        componentList.add(panelTitle);
        componentList.add(rdButton_ExistingConfigurationFile);
        componentList.add(rdButton_ConfigureNewPropertyFile);
        PagePanel buttonPanel = new PagePanel(componentList,new GroupLayout(this));
        this.add(buttonPanel, BorderLayout.CENTER);
        this.pack();
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        validate();
    }
}
    public class PagePanel extends JPanel {
    public PagePanel(List<JComponent> componentList, LayoutManager layOutManager) {
        this.setBackground(Color.decode("#4E6987"));
        if (layOutManager != null) {
            this.setLayout(null);
        }
        for (JComponent jComponent : componentList) {
            jComponent.setBackground(Color.decode("#4E6987"));
            this.add(jComponent);
        }
    }
}
Thanks in Advance Ravi Kumar
 
     
     
    