Icons disappear in gutter when scrolled with folding.

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Icons disappear in gutter when scrolled with folding.

Postby Tom K. » Tue May 15, 2012 6:25 pm

I've noticed a problem with icons disappearing in the gutter, when folding is enabled
and the window is scrolled. Here's a program that demonstrates this:

Code: Select all

Demonstrate disappearing icons in gutter when scrolled.

Run the program:

- Note: All folds are expanded, the scroll bar is positioned
at the bottom of its range.
- Scroll to the top.  Note the icons in the gutter every 10 lines.
- Use the popup menu: Folding->Collapse all folds.
  Note the icons are still visible in the gutter for the folds
  that fit in the window.
- Scroll down to the bottom.  Note that the icons do not appear on the
expected lines.
- Scroll back to the top.  Only the icon on line 1 is visible.
- Resize the window slightly to force a refresh.  The
icons within the visible region will reappear.
- Scroll to the bottom.  Resize the window slightly. Note
that the icons do not reappear.
- Resize the window so that all lines are visible.  All
of the icons in the gutter will be visible.

import java.awt.*;
import javax.swing.*;

import org.fife.ui.rtextarea.*;
import org.fife.ui.rsyntaxtextarea.*;
import javax.swing.text.BadLocationException;

public class FoldingTest extends JFrame {

  private static final long serialVersionUID = 1L;
  private TextEditorPane editPane;
  private RTextScrollPane sp;
  private Gutter gutter;
  private int nRegions = 10;

  public FoldingTest() throws java.io.IOException {

    JPanel cp = new JPanel(new BorderLayout());

    editPane = new TextEditorPane();

    sp = new RTextScrollPane(editPane);
    int width = 600;
    int height = 300;
    sp.setPreferredSize(new Dimension(width, height));


    // Set up gutter and icon
    gutter = sp.getGutter();

    // Add icons at regular intervals to the gutter.
    String iconName = "FileChooser.upFolderIcon";
    Icon icon = UIManager.getIcon(iconName);
    if (icon == null) {
      System.err.println("Could not find icon: " + iconName);

    for (int i=0; i < nRegions; ++i) {
      setIconOnLine(i*10 + 1, icon);

    setTitle("RSyntaxTextArea Gutter Icon Test");


  private void fillTextArea() {
    // add multiple non-nested folding regions

    for (int i=0; i<nRegions; ++i) {
      editPane.append("// loop " + i + "\n");
      editPane.append("for (;;) {");


  private void setIconOnLine(int lineNum, Icon icon) {
   try {
      gutter.addLineTrackingIcon(lineNum-1, icon);
    } catch (BadLocationException except) {

   public static void main(String[] args) {

      // Start all Swing applications on the EDT.
      SwingUtilities.invokeLater(new Runnable() {
         public void run() {
           try {
            FoldingTest demo = new FoldingTest();
           catch(java.io.IOException except) {




Tom K.
Tom K.

Re: Icons disappear in gutter when scrolled with folding.

Postby robert » Thu May 17, 2012 12:10 pm

Thanks Tom! I'll take a look.
User avatar
Posts: 852
Joined: Sat May 10, 2008 5:16 pm

Re: Icons disappear in gutter when scrolled with folding.

Postby robert » Tue May 29, 2012 3:32 am

Fixed in SVN revision 542. It will be included in the 2.0.4 release in a few weeks.
User avatar
Posts: 852
Joined: Sat May 10, 2008 5:16 pm

Return to Help

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 1 guest