I'm trying to call the method cardlayout.show to class below.
protected void makelabeltxt(final String text, GridBagLayout gridbag, GridBagConstraints c, int width, int height, final String panel) {
    final JLabel label = new JLabel(text);              
    Dimension d = new Dimension(width, height);
    gridbag.setConstraints(label, c);
    label.setFont(new Font("Sans Serif", 0, 11));
    label.setPreferredSize(d);
    label.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {                
            System.out.println(panel);
            fp.showPanel(panel);
            System.out.println("mouse clicked "+text);
        }
        @Override
        public void mousePressed(MouseEvent e) {
            label.setText("  " + text);
            System.out.println("mouse pressed "+text);
        }
        @Override
        public void mouseReleased(MouseEvent e) {
            label.setText(" " + text);
            System.out.println("mouse release "+text);
        }
        @Override
        public void mouseEntered(MouseEvent e) {
            label.setText(" " + text);
            System.out.println("mouse entered "+text);
        }
        @Override
        public void mouseExited(MouseEvent e) {
            label.setText(text);
        }
    });
    add(label);
}
In another class I've created method like this, this is the method i want to call. I want to swap jpanel, but in another jpanel: the method below is working but when cardlayout show script, it's nothing happen, the println script is fine
public void showPanel(String panel){
    System.out.println("panel : "+panel);       
    cl.show(mainInPanel, panel);
}
this is how i add JPanel to JPanel using cardlayout
public void initPanelFrm(JPanel panel, String gambar) {             
        GridBagLayout gridbag = new GridBagLayout();
        GridBagConstraints gbc = new GridBagConstraints();
        panel.setLayout(gridbag);
        panel.setPreferredSize(new Dimension(810, 280));
        panel.setBackground(Color.white);
        makelabelimg("com/reporting/image/"+gambar+".png", 444, 23, panel);     
        panel.setVisible(false);
        mainInPanel.add(panel, gambar); 
    }
    public void initInPanel(){
        rekappenjualanpsc = new JPanel();
        initPanelFrm(rekappenjualanpsc, "rekappenjualanpsc");
        rekapbastudenganmaskapai = new JPanel();
        initPanelFrm(rekapbastudenganmaskapai, "rekapbastudenganmaskapai");
        rekapitulasisetoranmaskapai = new JPanel();
        initPanelFrm(rekapitulasisetoranmaskapai, "rekapitulasisetoranmaskapai");
        rekappenjualanpscpermaskapai = new JPanel();
        initPanelFrm(rekappenjualanpscpermaskapai, "rekappenjualanpscpermaskapai");
        rekappungutanlangsungpsc = new JPanel();
        initPanelFrm(rekappungutanlangsungpsc, "rekappungutanlangsungpsc");
        laporandetailpetugas = new JPanel();
        initPanelFrm(laporandetailpetugas, "laporandetailpetugas");
        detailpembayaranpenumpang = new JPanel();
        initPanelFrm(detailpembayaranpenumpang, "detailpembayaranpenumpang");
    }
