package frames; import java.awt.BorderLayout; import javax.swing.JFrame; import panels.MainPanel; import panels.ShowHistoryPanel; import resources.CustomersModel; public class MainFrame extends JFrame implements IMainFrame { private CustomersModel model; private MainPanel mainPanel; private ShowHistoryPanel historyPanel; public MainFrame() { super("POS"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); model = new CustomersModel(); mainPanel = new MainPanel(this, model); historyPanel = new ShowHistoryPanel(this, model); historyPanel.setVisible(false); this.add(historyPanel, BorderLayout.CENTER); mainPanel.setVisible(true); this.add(mainPanel, BorderLayout.CENTER); this.pack(); } public void showMainPanel() { getContentPane().removeAll(); mainPanel.updateTableByTransition(); add(mainPanel); validate(); repaint(); } public void showHistoryPanel(int index) { getContentPane().removeAll(); historyPanel.setVisible(true); historyPanel.updateListModelByIndex(index); add(historyPanel); validate(); repaint(); } }