🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #978

Re: Saving a reference to a JTextPane

#978
From: Lori M Olson [TeamB]
Date: Tue, 15 Jun 2004 18:32
66 lines
2743 bytes
Wolf wrote:

>>Wolf wrote:
>>
>>
>>>Hi,
>>>
>>>I want to make several classes write messages to a JTextPane which has been created by one of them. I tried to save a reference to the pane in a class which controlls the user interface; later on I want to use this reference to write to the TextPane:
>>>
>>>JTextPane TextPane = new JTextPane();
>>>uic.setTextPane(TextPane);
>>>
>>>When setting TextPane to the uic slot I get a java.lang.NullPointerException
>>>
>>>What am I doing wrong?
>>>
>>>Regards
>>>
>>>Wolf
>>

> 
>  Lori,
>  
>  my idea was (and maybe I'm compleately wrong)
>  to store a reference to an existing TextPane
>  'somewhere', to make it accessable to diferent
>  clases. My controller has the following methods
>  for 'storing' and 'retrieving' the reference,
>  but even the 'set' produces the mentioned error.
>  Here follows the code for both methods.
>  
>  
>  public class UIController {
>  
>  ....
>  
>   public void setTextPane(JTextPane pane) {
>     TextPane = pane;
>   }
> 
>   public JTextPane getTextPane() {
>     return TextPane;
>   }
>   
>   ....
>   }
>   
>   Similar code works for passing around references
>   of, for example, trees, treenodes and treemodels.
>   I dont understand why it does'nt work with panes.
>   Is it posible that the pane is not really initialized 
>   till put into a type of container?
>   
>   Regards, Wolf
> 

Have you compiled using debug?  What line exactly is the NPE occurring 
on?  The only thing I can see is if your uic member is not yet 
initialized, you could get an NPE.

-- 

Regards,

Lori Olson [TeamB]
Technical Details
Message-ID: <40cf40e3@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40ceba2d$1@newsgroups.borland.com> <40cf10f8$1@newsgroups.borland.com> <40cf3c06$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,2de37b4a0a5af4c7
X-Google-Attributes: gid111d45,public
Date: Tue, 15 Jun 2004 12:32:20 -0600
From: "Lori M Olson [TeamB]" <javadragon@techie.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax; CDonDemand-Dom)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: Saving a reference to a JTextPane
References: <40ceba2d$1@newsgroups.borland.com> <40cf10f8$1@newsgroups.borland.com> <40cf3c06$1@newsgroups.borland.com>
In-Reply-To: <40cf3c06$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 142.179.181.200
Message-ID: <40cf40e3@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1087324387 142.179.181.200 (15 Jun 2004 11:33:07 -0700)
Lines: 67
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail