edu.rit.slides
Class ScreenChooser

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by edu.rit.slides.ScreenChooser
All Implemented Interfaces:
ScreenDiscoveryListener, Serializable, EventListener, ListSelectionListener, ListModel

public class ScreenChooser
extends AbstractListModel
implements ScreenDiscoveryListener, ListSelectionListener

Class ScreenChooser provides an object for choosing a theatre from a list of available theatres in the Slides application.

A screen chooser implements interface ScreenDiscoveryListener. A screen chooser object can be hooked up to a ScreenDiscoveryObject when the screen discovery object is constructed. The screen discovery object notifies the screen chooser whenever a theatre becomes available or unavailable, and the screen chooser updates the list of available theatres accordingly.

A screen chooser also implements interfaces ListModel and ListSelectionListener. A screen chooser can be hooked up to a Java Swing JList by calling the screen chooser's setJList() method. The screen chooser updates the JList display whenever the list of available theatres changes. The screen chooser also makes sure the same theatre stays selected in the JList when the list of available theatres changes. When the user selects a theatre from the JList display, the JList informs the screen chooser which theatre was selected.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
ScreenChooser(ScreenSelectionListener theListener)
          Construct a new screen chooser.
 
Method Summary
 Object getElementAt(int i)
          Returns the name of the theatre at the given index in the theatre list.
 int getSize()
          Returns the number of theatres in the theatre list.
 void selectTheatre(Screen theTheatre)
          Select the given theatre.
 void setJList(JList theJList)
          Set the JList associated with this screen chooser.
 void theatreAdded(Screen theHandle, String theName)
          Notify this screen chooser that a newly discovered theatre was added to the list of discovered theatres.
 void theatreNameChanged(Screen theHandle, String theName)
          Notify this screen discovery listener that an existing theatre's name was changed in the list of discovered theatres.
 void theatreRemoved(Screen theHandle)
          Notify this screen discovery listener that a previously discovered theatre was removed from the list of discovered theatres.
 void valueChanged(ListSelectionEvent e)
          Report that the theatre selection changed.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScreenChooser

public ScreenChooser(ScreenSelectionListener theListener)
Construct a new screen chooser.

Parameters:
theListener - Screen selection listener. If non-null, the listener will be notified whenever the selected theatre changes.
Method Detail

setJList

public void setJList(JList theJList)
Set the JList associated with this screen chooser.

Parameters:
theJList - JList.

theatreAdded

public void theatreAdded(Screen theHandle,
                         String theName)
Notify this screen chooser that a newly discovered theatre was added to the list of discovered theatres.

Specified by:
theatreAdded in interface ScreenDiscoveryListener
Parameters:
theHandle - Theatre multihandle implementing interface Screen.
theName - Theatre name.

theatreNameChanged

public void theatreNameChanged(Screen theHandle,
                               String theName)
Notify this screen discovery listener that an existing theatre's name was changed in the list of discovered theatres.

Specified by:
theatreNameChanged in interface ScreenDiscoveryListener
Parameters:
theHandle - Theatre multihandle implementing interface Screen.
theName - Theatre name.

theatreRemoved

public void theatreRemoved(Screen theHandle)
Notify this screen discovery listener that a previously discovered theatre was removed from the list of discovered theatres.

Specified by:
theatreRemoved in interface ScreenDiscoveryListener
Parameters:
theHandle - Theatre multihandle implementing interface Screen.

selectTheatre

public void selectTheatre(Screen theTheatre)
Select the given theatre. If theTheatre does not exist in the theatre list, the selected theatre is not changed. If theTheatre is null, a theatre of "" is selected.

Parameters:
theTheatre - Multihandle of the theatre to select.

getSize

public int getSize()
Returns the number of theatres in the theatre list.

Specified by:
getSize in interface ListModel

getElementAt

public Object getElementAt(int i)
Returns the name of the theatre at the given index in the theatre list.

Specified by:
getElementAt in interface ListModel
Parameters:
i - Index.
Returns:
Theatre name at index i.

valueChanged

public void valueChanged(ListSelectionEvent e)
Report that the theatre selection changed.

Specified by:
valueChanged in interface ListSelectionListener


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.