import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class CommandShowPanels implements ActionListener { private JPanel tab; private ZSBScreen screen; public CommandShowPanels(JPanel tab, ZSBScreen screen) { this.tab = tab; this.screen = screen; } public void actionPerformed(ActionEvent e) { try { this.tab.remove(1); } catch (Exception ArrayIndexOutOfBoundsException) { System.out.println(e); } if (this.screen.j != null) { this.tab.add("Center", this.screen.j.getPanels()); this.tab.repaint(); } } }