Skip to content

Commit

Permalink
Start Of Middle-Click Close
Browse files Browse the repository at this point in the history
  • Loading branch information
Konloch committed Sep 26, 2024
1 parent d811272 commit 6bfe74f
Showing 1 changed file with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public String getText() {
};

label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
label.setOpaque(false);
add(label);
JButton button = new CloseButton();
add(button);
Expand All @@ -64,13 +65,18 @@ public String getText() {
rightClickMenu.add(closeAllTabs);
rightClickMenu.add(closeTab);
button.setComponentPopupMenu(rightClickMenu);


//TODO add left-click close: when we add a new listener the parent listener (jTabbedPane) conflicts and won't respect the opaque flag.
// button.addMouseListener(new MouseClickedListener(e ->
// if (e.getButton() == MouseEvent.BUTTON2) // middle-click
// closePane();
// }));

button.addMouseListener(new MouseClickedListener(e ->
{
if (e.getButton() != MouseEvent.BUTTON1) // left-click
return;

closePane();
if (e.getButton() == MouseEvent.BUTTON2 // middle-click
|| e.getButton() == MouseEvent.BUTTON1) // left-click
closePane();
}));

closeTab.addActionListener(e ->
Expand Down Expand Up @@ -98,6 +104,20 @@ public String getText() {
setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}

public void selectPane()
{
if (pane.indexOfTabComponent(TabComponent.this) != -1)
{
int i = pane.indexOfTabComponent(TabComponent.this);
selectTab(i);
}
}

private void selectTab(int index)
{
BytecodeViewer.viewer.workPane.tabs.setSelectedIndex(index);
}

public void closePane()
{
if (pane.indexOfTabComponent(TabComponent.this) != -1)
Expand Down

0 comments on commit 6bfe74f

Please sign in to comment.