Can I insert small image instead line number?

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Can I insert small image instead line number?

Postby as3boyan » Fri Sep 20, 2013 4:12 pm

You know many IDEs shows bug, like small image placed on line number place. Maybe this is possible to do this via some custom renderer or something?
as3boyan
 
Posts: 19
Joined: Mon Sep 16, 2013 8:21 pm

Re: Can I insert small image instead line number?

Postby robert » Sat Sep 21, 2013 5:53 pm

Assuming you use an RTextScrollPane (which you should, for line numbers and code folding), you can add icons that track lines or specific offsets in the document via these methods on the Gutter:

java code:

Gutter.addLineTrackingIcon(int line, Icon icon)
Gutter.addLineTrackingIcon(int line, Icon icon, String toolTip)
Gutter.addOffsetTrackingIcon(int offs, Icon icon)
Gutter.addOffsetTrackingIcon(int offs, Icon icon, String toolTip)


Example:

java code:

RSyntaxTextArea textArea = new RSyntaxTextArea(40, 25);
RTextScrollPane scrollPane = new RTextScrollPane(textArea, true);
scrollPane.setFoldIndicatorEnabled(true);
scrollPane.setIconRowHeaderEnabled(true);
Icon errorIcon = new ImageIcon(getClass().getResource(...));

// ...

textArea.setText("line 1\nline 2\nline 3");
GutterIconInfo tag = scrollPane.getGutter().addLineTrackingIcon(1, errorIcon);
User avatar
robert
 
Posts: 785
Joined: Sat May 10, 2008 5:16 pm

Re: Can I insert small image instead line number?

Postby as3boyan » Tue Sep 24, 2013 5:28 pm

Robert, thank you so much! :)
as3boyan
 
Posts: 19
Joined: Mon Sep 16, 2013 8:21 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests

cron