From 17c8bdebf4f412f8bebc108758a0249bcd4ce594 Mon Sep 17 00:00:00 2001 From: davidepastore Date: Sat, 17 Oct 2015 18:24:38 +0200 Subject: [PATCH] Add "close on middle mouse click on the tab" support --- .../jd/gui/view/component/panel/TabbedPanel.groovy | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/groovy/org/jd/gui/view/component/panel/TabbedPanel.groovy b/app/src/main/groovy/org/jd/gui/view/component/panel/TabbedPanel.groovy index 6d8a8b8f..74d5b27e 100644 --- a/app/src/main/groovy/org/jd/gui/view/component/panel/TabbedPanel.groovy +++ b/app/src/main/groovy/org/jd/gui/view/component/panel/TabbedPanel.groovy @@ -15,6 +15,7 @@ import javax.swing.JComponent import javax.swing.JMenu import javax.swing.JMenuItem import javax.swing.JPopupMenu +import javax.swing.SwingUtilities import javax.swing.ToolTipManager import javax.swing.event.ChangeEvent import java.awt.BorderLayout @@ -115,6 +116,17 @@ class TabbedPanel extends JPanel implements PreferencesChangeListener { tab.toolTipText = tip tab.add(new JLabel(title, icon, JLabel.LEADING), BorderLayout.CENTER) tab.add(tabCloseButton, BorderLayout.EAST) + tab.addMouseListener(new MouseListener() { + void mousePressed(MouseEvent e) {} + void mouseReleased(MouseEvent e) {} + void mouseEntered(MouseEvent e) { } + void mouseExited(MouseEvent e) {} + void mouseClicked(MouseEvent e) { + if(SwingUtilities.isMiddleMouseButton(e)) { + removeComponent(page) + } + } + }) ToolTipManager.sharedInstance().unregisterComponent(tab) int index = tabbedPane.getTabCount()