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


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

Re: Sharing ListSelection

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.alt.net!news-in-01.newsfeed.easynews.com!easynews.com!easynews!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this>
Subject Re: Sharing ListSelection
Message-ID <48f8a154$1@news.uni-rostock.de> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <0bmdnV7u3oxyCWXVnZ2dnUVZ_r6dnZ2d@comcast.com>
References <0bmdnV7u3oxyCWXVnZ2dnUVZ_r6dnZ2d@comcast.com>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 30
Date Wed, 27 Apr 2011 15:50:15 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303919415 96.60.20.240 (Wed, 27 Apr 2011 10:50:15 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:50:15 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:4380

Show key headers only | View raw


  To: comp.lang.java.gui
 >...
> Stefan Rybacki wrote:
>> Well I don't have any action listener attached. And I can't change the 
>> code that notifies the listener.
> 
> If you haven't got any listeners attached, how is there "code that 
> notifies the listener"?
> 
The listeners are coming from the GUI element itself. A JList automatically 
attaches a ListDataListener to the model and a ListSelectionListener to the 
selection model. The same applies to the JTable.
So basically what I do is provide a model that is wrapped once in a TableModel 
and also wrapped in a ListModel. Those models are then attached to either JList 
and JTable. While being 2 different model object they wrap the same model in the 
background. Additionally I create a DefaultListSelectionModel add attach them to 
the table and the list
So again, what happens is. When I e.g. add an item to the main model. Both the 
table and the list are notified since they attached 
ListDataListeners/TableModelListener to the model. Additionally they internally 
notify the selection model because there was an item added and therefore some 
selections might need to be moved one up. But since both table and list do this
selections are moved up twice.

Stefan

---
 * 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 | Next in thread | Find similar


Thread

Sharing ListSelectionMode "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
  Re: Sharing ListSelection "Sabine Dinis Blochberger" <sabine.dinis.blochberger@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
    Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
      Re: Sharing ListSelection "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
        Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
          Re: Sharing ListSelection "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
            Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
              Re: Sharing ListSelection "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
            Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000

csiph-web