Code
class ParagraphMarkHighlightPainter extends DefaultHighlightPainter {
protected ParagraphMarkHighlightPainter(Color color) {
super(color);
}
@Override public Shape paintLayer(
Graphics g, int offs0, int offs1,
Shape bounds, JTextComponent c, View view) {
Shape s = super.paintLayer(g, offs0, offs1, bounds, c, view);
Rectangle r = s.getBounds();
if (r.width - 1 <= 0) {
g.fillRect(r.x + r.width, r.y, r.width + r.height / 2, r.height);
}
return s;
}
}
class WholeLineHighlightPainter extends DefaultHighlightPainter {
protected WholeLineHighlightPainter(Color color) {
super(color);
}
@Override public Shape paintLayer(
Graphics g, int offs0, int offs1,
Shape bounds, JTextComponent c, View view) {
Rectangle rect = bounds.getBounds();
rect.width = c.getSize().width;
return super.paintLayer(g, offs0, offs1, rect, c, view);
}
}
References
No comments:
Post a Comment