what's the use of SelectionModels?

Discussion in 'Java' started by Abs, Jun 19, 2004.

  1. Abs

    Abs Guest

    Hi!

    I hope you can enlighten me but I don't see the use of
    SelectionModels when JList, JTable, etc. have methods to work with
    selections. Why do you use SelectionModels ?


    Regards
    Abs, Jun 19, 2004
    #1
    1. Advertising

  2. Abs

    Chris Smith Guest

    Abs wrote:
    > I hope you can enlighten me but I don't see the use of
    > SelectionModels when JList, JTable, etc. have methods to work with
    > selections. Why do you use SelectionModels ?


    SelectionModel is quite useful when you want to change the basic way
    that selection works for those components. For example, perhaps you
    want a JTree component to only allow selection of leaf nodes; the
    selection model can be used to accomplish this trivially.

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
    Chris Smith, Jun 21, 2004
    #2
    1. Advertising

  3. Abs schrieb:
    > Hi!
    >
    > I hope you can enlighten me but I don't see the use of SelectionModels
    > when JList, JTable, etc. have methods to work with selections. Why do
    > you use SelectionModels ?


    There are a couple of reasons for using a SelectionModel. A model
    notifies it's listeners whenever it changes.

    Imagine a file chooser. On the left side there's a tree containing
    directories, on the right side there are the details of the current
    selected directory (the selection).

    What one expects in such situations is, that if he selects a directory
    in the directory tree, the details are updated. To do this, you register
    a TreeSelectionListener with the tree's TreeSelectionModel and from this
    time on your listener is notified whenever the selection set changes.

    Bye
    Michael
    Michael Rauscher, Jun 21, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    6
    Views:
    7,104
  2. M K
    Replies:
    11
    Views:
    7,041
    woods_jemmy
    Apr 9, 2008
  3. Simon
    Replies:
    1
    Views:
    445
    Henri
    Nov 9, 2004
  4. =?Utf-8?B?S2hhaXJvbA==?=
    Replies:
    0
    Views:
    352
    =?Utf-8?B?S2hhaXJvbA==?=
    Dec 10, 2004
  5. =?Utf-8?B?SmVmZiBLZXNpbmdlcg==?=

    Common Web functions dll (Used to use MTS, what do I use in .NET

    =?Utf-8?B?SmVmZiBLZXNpbmdlcg==?=, Dec 28, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    461
    charlie
    Apr 30, 2005
Loading...

Share This Page