forked from CYS4srl/SensitiveDiscoverer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from CYS4srl/master
Update SensitiveDiscoverer extension to v3.2.1
- Loading branch information
Showing
5 changed files
with
55 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/cys4/sensitivediscoverer/ui/MenuButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.cys4.sensitivediscoverer.ui; | ||
|
||
import javax.swing.*; | ||
import javax.swing.event.PopupMenuEvent; | ||
import javax.swing.event.PopupMenuListener; | ||
|
||
public class MenuButton extends JToggleButton { | ||
private final JPopupMenu popup; | ||
|
||
public MenuButton(String name, JPopupMenu menu) { | ||
super(name); | ||
this.popup = menu; | ||
addActionListener(ev -> { | ||
JToggleButton b = MenuButton.this; | ||
if (b.isSelected()) { | ||
popup.show(b, 0, b.getBounds().height); | ||
} else { | ||
popup.setVisible(false); | ||
} | ||
}); | ||
popup.addPopupMenuListener(new PopupMenuListener() { | ||
@Override | ||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {} | ||
@Override | ||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { | ||
MenuButton.this.setSelected(false); | ||
} | ||
@Override | ||
public void popupMenuCanceled(PopupMenuEvent e) {} | ||
}); | ||
} | ||
} |