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 c6db7da698
commit baf55a4c96
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13

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);
} }
} }