question: protected Object openObject ( ) { if ( m_FileChooser == null ) { createFileChooser ( ) ; } int returnVal = m_FileChooser . showOpenDialog ( this ) ; if ( returnVal == JFileChooser . APPROVE_OPTION ) { File selected = m_FileChooser . getSelectedFile ( ) ; try { ObjectInputStream oi = new ObjectInputStream ( new BufferedInputStream ( new FileInputStream ( selected ) ) ) ; Object obj = oi . readObject ( ) ; oi . close ( ) ; if ( ! m_ClassType . isAssignableFrom ( obj . getClass ( ) ) ) { throw new Exception ( "Object not of type: " + m_ClassType . getName ( ) ) ; } return obj ; } catch ( Exception ex ) { JOptionPane . showMessageDialog ( this , "Couldn't read object: " + selected . getName ( ) + "\n" + ex . getMessage ( ) , "Open object file" , JOptionPane . ERROR_MESSAGE ) ; } } return null ; }
target:  Opens an object from a file selected by the user.