diff --git a/src/lsystem/screen/main/Listener.java b/src/lsystem/screen/main/Listener.java index 261583f..5c4e83a 100644 --- a/src/lsystem/screen/main/Listener.java +++ b/src/lsystem/screen/main/Listener.java @@ -31,11 +31,13 @@ public class Listener implements ActionListener, KeyListener, MouseWheelListener public void actionPerformed(ActionEvent e) { switch (type) { case "Close": - frame.getTab().removeTabAt(index-1); - frame.decreaseTab(); - for(int i = 0; i < frame.getTab().getComponentCount(); i++){ - frame.getTab().setTitleAt(i,"Génération"+(i+1)); + Component selected = frame.tabs.getSelectedComponent(); + if (selected != null) { + + frame.tabs.remove(selected); } + frame.decreaseTab(); + frame.renameTabs(); break; case "Help": diff --git a/src/lsystem/screen/main/MainFrame.java b/src/lsystem/screen/main/MainFrame.java index 8ab7240..70486ee 100644 --- a/src/lsystem/screen/main/MainFrame.java +++ b/src/lsystem/screen/main/MainFrame.java @@ -16,7 +16,7 @@ public class MainFrame extends JFrame { private int nbTabs; boolean helpWindow = false; private final JPanel basePanel; - private final JTabbedPane tabs; + public final JTabbedPane tabs; private final JButton newGen; private final JButton help; private final int nbRules; @@ -49,6 +49,7 @@ public class MainFrame extends JFrame { nbTabs++; new Tab(nbTabs, nbRules, tabs,this); + renameTabs(); } public JTabbedPane getTab(){ return tabs; @@ -98,5 +99,10 @@ public class MainFrame extends JFrame { } } + public void renameTabs(){ + for(int i =0;i