🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: making sense of runtime error

#773
From: Alan Shiers
Date: Wed, 22 Dec 2004 16:53
44 lines
2303 bytes
Hi there,

The JScrollPane is definitely trying to repaint itself, but failing for some
reason.
Just for your further information...my project is not that complicated.  My
main class that extends JFrame declares an instance of JScrollPane at the
top, then loads the JScrollPane in an actionPerformed method like so:

public class test extends JFrame implements ActionListener
{
  JScrollPane sp2 = new JScrollPane();
  DocumentPanel docPanel = null;
  JMenuItem New = new JMenuItem("New");
  ...

  public void actionPerformed(ActionEvent e)
  {
     if(e.getSource() == New)
     {
        Thread newThread = new Thread()
         {
            public void run()
            {
               //Display a new DocumentPanel
               docPanel = new DocumentPanel();
               sp2.getViewport().add(docPanel);
               container.add(sp2,BorderLayout.CENTER);
               container.validate();
            }
         };
       newThread.start();
     }
  }
}
[/code]

docPanel is an object I created that extends JPanel and contains many other
objects.

In the same actionPerformed() method is the code for saving the docPanel
seen in the earlier post.  So, any further ideas as to how to prevent the
NullPointerException I've been getting with the JScrollPane?

Alan
Technical Details
Message-ID: <41c9a796$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!63.218.45.10.MISMATCH!newshosting.com!nx01.iad01.newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41c887e9$1@newsgroups.borland.com> <41c98187$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,a48625165a64e13d
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Alan Shiers" <ashiers@hfx.eastlink.ca>
Newsgroups: borland.public.jbuilder.java.swing
References: <41c887e9$1@newsgroups.borland.com> <41c98187$1@newsgroups.borland.com>
Subject: Re: making sense of runtime error
Date: Wed, 22 Dec 2004 12:53:46 -0400
Lines: 46
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 24.222.101.2
Message-ID: <41c9a796$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1103734678 24.222.101.2 (22 Dec 2004 08:57:58 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!63.218.45.10.MISMATCH!newshosting.com!nx01.iad01.newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail