Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3889

Re: Avoiding NPEs caused

From "Mark Space" <mark.space@THRWHITE.remove-dii-this>
Subject Re: Avoiding NPEs caused
Message-ID <r4Rlk.16315$xZ.9430@nlpi070.nbdc.sbc.com> (permalink)
Newsgroups comp.lang.java.gui
References <8d61e9e0-b62d-425a-9a95-ca7ac9e8ea49@d77g2000hsb.googlegroups.com>
Date 2011-04-27 15:47 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.programmer
Royan wrote:

> And the second one (which has made me to start this thread) was when I
> derived from the JDialog and overridden addXxxx and fireXxx methods.
> Because this case is somewhat easier to reproduce I've written a very
> small test case that demonstrates my original problem:

Your original test case was excellent, no worries.  I think however now 
that we know you base class is JDialog... I'm not sure there's much to 
be done.  Apparently, JDialog is poorly designed for the type of 
inheritance you want to do.  So, you can't do that.

I'm not sure what's up with the property change listener.  I've never 
used one (directly) and I don't know why it's firing in the constructor. 
  There might be a better way of using the property change listener.

Some things you might consider:

1. Wrap the JDialog instead of extending it.

class SampleDialog {
   private JDialog jd;
   private PropertyChangeSupport pcs;

   //... etc.
}

2. Extend java.awt.dialog instead of JDialog.

3. Look into other ways to use property change listeners.

#3 seems like the first thing you should do.  While JDialog might not be 
the best class to extend, I don't see why you can't extend 
DefaultTableModel (although it may not be designed for inheritance 
either.  AbstractTableModel seems to be the class to extend.)  So you 
might be doing something iffy with the property change listeners here. 
I'm not really sure because I don't have any experience with them.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Avoiding NPEs caused "Royan" <royan@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
  Re: Avoiding NPEs caused "Mark Space" <mark.space@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
    Re: Avoiding NPEs caused "Royan" <royan@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
      Re: Avoiding NPEs caused "Mark Space" <mark.space@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000

csiph-web