diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabComponent.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabComponent.java index fe1bec2e..0df47816 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabComponent.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabComponent.java @@ -12,12 +12,16 @@ import java.awt.event.MouseEvent; public class TabComponent extends JPanel { + private JTabbedPane pane; + public TabComponent(final JTabbedPane pane) { super(new FlowLayout(FlowLayout.LEFT, 0, 0)); if (pane == null) { throw new NullPointerException("TabbedPane is null"); } + this.pane = pane; + setOpaque(false); JLabel label = new JLabel() { public String getText() { @@ -51,7 +55,6 @@ public class TabComponent extends JPanel { if (pane.indexOfTabComponent(TabComponent.this) != -1) { int i = pane.indexOfTabComponent(TabComponent.this); removeTab(i); - pane.remove(pane.indexOfTabComponent(TabComponent.this)); } })); @@ -60,7 +63,6 @@ public class TabComponent extends JPanel { if (pane.indexOfTabComponent(TabComponent.this) != -1) { int i = pane.indexOfTabComponent(TabComponent.this); removeTab(i); - pane.remove(pane.indexOfTabComponent(TabComponent.this)); } }); @@ -73,10 +75,8 @@ public class TabComponent extends JPanel { if (pane.indexOfTabComponent(TabComponent.this) != 0) { removeTab(0); - pane.remove(0); } else { removeTab(1); - pane.remove(1); } } }); @@ -87,6 +87,7 @@ public class TabComponent extends JPanel { private void removeTab(int index) { ResourceViewer resourceViewer = (ResourceViewer) BytecodeViewer.viewer.workPane.tabs.getComponentAt(index); BytecodeViewer.viewer.workPane.openedTabs.remove(resourceViewer.resource.workingName); + pane.remove(index); } }