Added simple close button to tab component

This commit is contained in:
Kai S. K. Engelbart 2019-12-11 14:11:24 +01:00
parent 17d2080e27
commit cb79cc3159

View File

@ -2,6 +2,7 @@ package dev.kske.chess.ui;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTabbedPane; 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);
} }
} }