#19 NPE in parameterless Constructor of RTextScrollPane()

closed-fixed
Gutter (2)
5
2012-07-29
2012-04-22
Dieter Rehbein
No

a call to

new RTextScrollPane()

always throws an NPE. To fix this, I've added an if(textArea!=null):

public RTextScrollPane(RTextArea area, boolean lineNumbers,
Color lineNumberColor) {

super(area);

// Create the text area and set it inside this scroll bar area.
textArea = area;

if (textArea!=null) {
// Create the gutter for this document.
Font defaultFont = new Font("Monospaced", Font.PLAIN, 12);
gutter = new Gutter(textArea);
gutter.setLineNumberFont(defaultFont);
gutter.setLineNumberColor(lineNumberColor);
setLineNumbersEnabled(lineNumbers);
}

// Set miscellaneous properties.
setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_ALWAYS);
setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_AS_NEEDED);

}

the attached file contains the fix.

Discussion

  • Dieter Rehbein
    Dieter Rehbein
    2012-04-22

     
    Attachments
  • Robert Futrell
    Robert Futrell
    2012-07-29

    This is fixed in SVN, and will be fixed in the upcoming version 2.0.4. It may have been fixed in the most recent version, 2.0.3, as well.

     
  • Robert Futrell
    Robert Futrell
    2012-07-29

    • labels: --> Gutter
    • assigned_to: nobody --> robert_futrell
    • status: open --> closed-fixed