1 / 5

Opening Files with JFileChooser

Opening Files with JFileChooser. The class JFileChooser Enables the user to easily select files or directories JFileChooser method setFileSelectionMode Specifies what the user can select from the file chooser JFileChooser static constant FILES_AND_DIRECTORIES indicates that

lvine
Download Presentation

Opening Files with JFileChooser

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Opening Files with JFileChooser • The class JFileChooser • Enables the user to easily select files or directories • JFileChooser method setFileSelectionMode • Specifies what the user can select from the file chooser • JFileChooser static constant • FILES_AND_DIRECTORIES indicates that • files and directories can be selected. • Method showOpenDialog displays • a JFileChooser dialog titled Open.

  2. Opening Files with JFileChooser • A JFileChooser dialog is a modal dialog box. • Method showOpenDialog • returns an integer specifying which • button (Open or Cancel) the user clicked to close the dialog • JFileChooser method getSelectedFile • returns the selected file as a File object.

  3. Playing Video and Other Media with Java Media Framework • static Manager method setHint • specifies rendering hints to the Manager. • e.g., instructs the Manager to use a lightweight renderer • that is compatible with lightweight Swing components, • as opposed to the default heavyweight renderer. • static method createRealizedPlayer of Manager • creates and realizes a Player that plays the media file. • When a Player realizes, it identifies the system resources • it needs to play the media. • Depending on the file, realizing can be • a resource-consuming and time-consuming process.

  4. Playing Video and Other Media with JMF • Throws three checked exceptions, • NoPlayerException, • CannotRealizeException and • IOException. • A NoPlayerException indicates that the system • could not find a player that can play the file format. • A CannotRealizeException indicates that the system • could not properly identify the resources a media file needs. • An IOException indicates that • there was an error while reading the file.

  5. Playing Video and Other Media with JMF (cont’d) • Player method getVisualComponent gets • a Component that displays the visual (generally video) aspect • of the media file. • Player method getControlPanelComponent gets • a Component that provides playback and media controls. • Player method start begins playing a media file. • Method toURI of class File returns a URI that • points to the File on the system. • Then, method toURL of class URI get the file’s URL.

More Related