Skip to content

Commit

Permalink
Add "close on middle mouse click on the tab" support
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidePastore committed Oct 17, 2015
1 parent acd511f commit 17c8bde
Showing 1 changed file with 12 additions and 0 deletions.
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 Down Expand Up @@ -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()
Expand Down

0 comments on commit 17c8bde

Please sign in to comment.