public void valueChanged ( ListSelectionEvent e ) { int index = this . getSelectedIndex ( ) ; if ( index != - 1 ) { int hour = index / 2 ; int minute = ( int ) ( ( ( float ) index / 2 - hour ) * 60 ) ; calendar . setTime ( targetTime ) ; calendar . set ( Calendar . HOUR_OF_DAY , hour ) ; calendar . set ( Calendar . MINUTE , minute ) ; Date date = calendar . getTime ( ) ; JPopupMenu popupMenu = this . getJPopupMenu ( ) ; if ( popupMenu != null ) { // I'm not sure this is the correct code, but here it is! Component invoker = popupMenu . getInvoker ( ) ; this . getParent ( ) . remove ( this ) ; // Just being careful Container container = popupMenu . getParent ( ) ; popupMenu . setVisible ( false ) ; container . remove ( popupMenu ) ; if ( invoker != null ) if ( transferFocus ) invoker . transferFocus ( ) ; // Focus on next component after invoker } Date oldTime = selectedTime ; if ( selectedTime == targetTime ) oldTime = null ; this . firePropertyChange ( m_strDateParam , oldTime , date ) ; } }
Called whenever the value of the selection changes .