Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "close on middle mouse click on the tab" support #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,7 +32,6 @@ import javax.swing.ImageIcon
import javax.swing.JLabel
import javax.swing.JPanel
import javax.swing.JTabbedPane
import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent
import java.awt.event.MouseListener

Expand Down Expand Up @@ -70,7 +70,7 @@ class TabbedPanel extends JPanel implements PreferencesChangeListener {
}
}
ToolTipManager.sharedInstance().registerComponent(tabPanel)
tabPanel.addMouseListener(new MouseAdapter() {
tabPanel.addMouseListener(new MouseListener() {
void mousePressed(MouseEvent e) { showPopupTabMenu(e) }
void mouseReleased(MouseEvent e) { showPopupTabMenu(e) }
void showPopupTabMenu(MouseEvent e) {
Expand All @@ -81,6 +81,14 @@ class TabbedPanel extends JPanel implements PreferencesChangeListener {
}
}
}
void mouseEntered(MouseEvent e) {}
void mouseExited(MouseEvent e) {}
void mouseClicked(MouseEvent e) {
int index = tabPanel.indexAtLocation(e.x, e.y)
if (index != -1 && SwingUtilities.isMiddleMouseButton(e)) {
removeComponent(tabPanel.getComponentAt(index))
}
}
})
return tabPanel
}
Expand Down