Skip to content

Commit

Permalink
Middle Mouse Button closes tab. Closes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
deathmarine committed Aug 25, 2016
1 parent 7b35560 commit 5e41ff7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/us/deathmarine/luyten/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,23 @@ private void addOrSwitchToTab(final OpenFile open) {
@Override
public void run() {
try {
String title = open.name;
final String title = open.name;
RTextScrollPane rTextScrollPane = open.scrollPane;
if (house.indexOfTab(title) < 0) {
house.addTab(title, rTextScrollPane);
house.setSelectedIndex(house.indexOfTab(title));
int index = house.indexOfTab(title);
Tab ct = new Tab(title);
ct.getButton().addMouseListener(new CloseTab(title));
ct.addMouseListener(new MouseAdapter(){
@Override
public void mouseClicked(MouseEvent e) {
if(SwingUtilities.isMiddleMouseButton(e)){
int index = house.indexOfTab(title);
closeOpenTab(index);
}
}
});
house.setTabComponentAt(index, ct);
} else {
house.setSelectedIndex(house.indexOfTab(title));
Expand Down

0 comments on commit 5e41ff7

Please sign in to comment.