From cb79cc315992b736c9db777ab2f8a3ba0a7d7d24 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Wed, 11 Dec 2019 14:11:24 +0100 Subject: [PATCH] Added simple close button to tab component --- src/dev/kske/chess/ui/GameTabComponent.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dev/kske/chess/ui/GameTabComponent.java b/src/dev/kske/chess/ui/GameTabComponent.java index e436348..c9b6bff 100644 --- a/src/dev/kske/chess/ui/GameTabComponent.java +++ b/src/dev/kske/chess/ui/GameTabComponent.java @@ -2,6 +2,7 @@ package dev.kske.chess.ui; import java.awt.FlowLayout; +import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; @@ -33,6 +34,11 @@ public class GameTabComponent extends JPanel { } }); - // TODO: Add closing button + JButton btnClose = new JButton("Close"); + btnClose.addActionListener((evt) -> { + int i = tabbedPane.indexOfTabComponent(GameTabComponent.this); + if (i != -1) tabbedPane.remove(i); + }); + add(btnClose); } }