RTextArea NullPointerException

Questions on using RSyntaxTextArea should go here.

Moderator: robert

RTextArea NullPointerException

Postby Taneeda » Thu Jun 25, 2009 9:16 am

Hi,

I get a NullPointerException for RTextArea if i initialize the text in constructor
Code: Select all
rTextArea = new RTextArea(uo);

but no exception when
Code: Select all
rTextArea = new RTextArea();
rTextArea.setText(uo);


Here, the complete code of the class:
Code: Select all
package client.view.guicomponents;

import javax.swing.ImageIcon;
import javax.swing.JDialog;
import org.fife.ui.rtextarea.RTextArea;
import org.fife.ui.rtextarea.RTextScrollPane;
import client.controls.IconLocations;
import client.lib.LibGui;
import client.view.Gui;

/**
 * @brief The class extends to JDialog to create a modal dialog that shows
 * the delivered object.
 *
 * @author Ronald
 */
public class GuiDialogTreeLeafShow extends JDialog
{
   /**
    * The generated serial id for this component.
    */
   private static final long serialVersionUID = -8516683303694899985L;
   
   /**
    * The reference to the scroll pane that contains the text area.
    */
   private RTextScrollPane jScrollPane = null;
   
   /**
    * The text area that displays the string.
    */
   private RTextArea rTextArea = null;

   /**
    * The constructor initializes the dialog window and displays it.
    *
    * @param uo The object to displays (.toString()).
    */
   public GuiDialogTreeLeafShow(Object uo)
   {
>>>>>   super(Gui.getInstance().getJFrame()); // Own class
      setIconImage(new ImageIcon(getClass().getClassLoader().getResource(
         IconLocations.ICON_DIALOG_TREE_LEAF)).getImage());
      if(uo.toString().length() <= 50)
      {
         setTitle(uo.toString());
      }
      else if(uo.toString().length() > 50)
      {
         setTitle(uo.toString().substring(0, 50) + "...");
      }
      setContentPane(getJScrollPane(uo.toString()));
      
      setSize(200, 250);
      LibGui.setLocationToScreenMiddle(this);
      validate();
      setVisible(true);
   }
   
   /**
    * The method creates the scroll pane that contains the text area.
    *
    * @return The reference to the scroll pane.
    */
   private RTextScrollPane getJScrollPane(String uo)
   {
      if(jScrollPane == null)
      {
         jScrollPane = new RTextScrollPane(getRTextArea(uo));
      }
      
      return jScrollPane;
   }
   
   /**
    * The method creates the text area and initializes the text.
    *
    * @param uo The string to display in text area.
    * @return
    */
   private RTextArea getRTextArea(String uo)
   {
      if(rTextArea == null)
      {
         rTextArea = new RTextArea();
         rTextArea.setText(uo);
      }
      
      return rTextArea;
   }
}


Greetz Taneeda
Image
User avatar
Taneeda
 
Posts: 10
Joined: Fri Jun 19, 2009 12:35 pm
Location: Oldenburg, Germany

Re: RTextArea NullPointerException

Postby robert » Thu Jun 25, 2009 1:00 pm

Thanks for the bug report! This will be trickier to fix than most, but since the "workarounds" are so simple, it really isn't a big deal.

I've opened a tracker for this issue on SourceForge.

Thanks!
User avatar
robert
 
Posts: 794
Joined: Sat May 10, 2008 5:16 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron