🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
5 messages
5 total messages Started by Wolf Tue, 15 Jun 2004 08:58
Saving a reference to a JTextPane
#975
Author: Wolf
Date: Tue, 15 Jun 2004 08:58
15 lines
1204 bytes
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
Re: Saving a reference to a JTextPane
#976
Author: Lori M Olson [TeamB]
Date: Tue, 15 Jun 2004 15:07
37 lines
2033 bytes
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

So where is the code for the setTextPane method?

-- 

Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
     http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
     http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
     http://www.visi.com/~gyles19/fom-serve/cache/1.html
Re: Saving a reference to a JTextPane
#977
Author: Wolf
Date: Tue, 15 Jun 2004 18:12
72 lines
2765 bytes
"Lori M Olson [TeamB]" <javadragon@techie.com> 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
>
>So where is the code for the setTextPane method?
>
>-- 
>
>Regards,
>
>Lori Olson [TeamB]
>
>------------
>
>Save yourself, and everyone else, some time and search the
>newsgroups and the FAQ-O-Matic before posting your next
>question.
>
>Google Advanced Newsgroup Search
>     http://www.google.ca/advanced_group_search
>Other Newsgroup Searches:
>     http://www.borland.com/newsgroups/ngsearch.html
>Joi Ellis's FAQ-O-Matic:
>     http://www.visi.com/~gyles19/fom-serve/cache/1.html
>
 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
Re: Saving a reference to a JTextPane
#978
Author: 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]
Re: Saving a reference to a JTextPane
#785
Author: John McGrath [TeamB]
Date: Thu, 17 Jun 2004 05:22
18 lines
1313 bytes
On 6/15/2004 at 4:58:21 AM, Wolf wrote:

> uic.setTextPane(TextPane);
> 
> When setting TextPane to the uic slot I get a
> java.lang.NullPointerException

If you are getting an NPE on this line of code, it seems likely that the
problem is that "uic" is null.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads