Close tab when middle click

This commit is contained in:
Nico Mexis 2021-06-22 12:52:12 +02:00
parent 87fc6c8435
commit 85ba5bbb11
No known key found for this signature in database
GPG key ID: 27D6E17CE092AB78

View file

@ -94,6 +94,18 @@ public class TabbedPane extends JPanel {
}
};
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON2) {
final int i = pane.indexOfTabComponent(TabbedPane.this);
if (i != -1) {
pane.remove(i);
}
}
}
});
this.add(label);
// add more space between the label and the button
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));