Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

About JList listener

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Coders!
Im developing a chat program. I diside to use Jlist as a dissection protocol.
I decided to use a Jlist because I have to register such a listener that able to tell me when a new element were added to the list and in addition one that can scroll the list to old element that been previously added to the list.
I�ve looked for it in the API , I find two listeners that can do the job: ListSelectionListener and ListDataListener. I couldn�t find the difference between them both.
can anyone explain? , what the correct combination to use in my case?
Also I have some question about using Jlist,
Can I change one chars color within an element?
Does the number of elements are limited in DataList,vector , and if yes how can I reload it dynamically?
Thanks
Shay Gaghe
 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shay Gaghe:

I�ve looked for it in the API , I find two listeners that can do the job: ListSelectionListener and ListDataListener. I couldn�t find the difference between them both.
can anyone explain? , what the correct combination to use in my case?


Under the JList hide two models: A ListModel, which contains the data of your list and a ListSelectionModel, which handles the selection on your list (what element or elements are selected).
You can put a ListDataListener on a ListModel and you will the be notified when elements are added or removed (that's what you are looking for), and a ListSelectionListener on a ListSelectionModel and you will be notified when the selection changes (This one can be directly added on an instance of JList).
W.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic