GutterHandler
which allows to:
Show a specific image on specific lines
Have a custom behavior upon clicking on the Gutter
Have a custom behavior upon hovering on a line the gutter, such as for example showing a tooltip
Example
The following handler:
Handles a right-click on the gutter and shows a menu for each line
Shows a tooltip on lines which paint an image
private class MyGutterHandler extends AbstractGutterHandler {
public boolean handleClick(Gutter gutter, int mouseButton, int x, int y) {
if (mouseButton == MouseEvent.BUTTON3) {
JPopupMenu menu = new JPopupMenu();
int number = gutter.getLineNumber(y);
menu.add(new JMenuItem("An Action on " + number));
menu.show(gutter, x, y);
return true;
} else {
return false;
}
}
public void handleMoved(Gutter gutter, int x, int y) {
int number = gutter.getLineNumber(y);
if (isPainting(number)) {
this.showTooltip("The tooltip on line" + number);
} else {
this.hideTooltip();
}
}
}
Copyright © 2016, 2017, 2018, 2019, 2023 Herve Girod. All Rights Reserved. Documentation and source under the MIT licence