Close tab when middle click
This commit is contained in:
parent
87fc6c8435
commit
85ba5bbb11
1 changed files with 12 additions and 0 deletions
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue