API for seesaw.chooser - Seesaw

by Dave Ray

Full namespace name: seesaw.chooser

Overview

File chooser and other common dialogs.

Public Variables and Functions



choose-color

function
Usage: (choose-color & args)
Choose a color with a color chooser dialog. The optional first argument is the
parent component for the dialog. The rest of the args is a list of key/value 
pairs:

        :color The initial selected color (see seesaw.color/to-color)
        :title The dialog's title

Returns the selected color or nil if canceled.

See:
  http://download.oracle.com/javase/6/docs/api/javax/swing/JColorChooser.html


choose-file

function
Usage: (choose-file & args)
Choose a file to open or save. The arguments can take two forms. First, with
an initial parent component which will act as the parent of the dialog.

    (choose-file dialog-parent ... options ...)

If the first arg is omitted, the desktop is used as the parent of the dialog:

    (choose-file ... options ...)

Options can be one of:

  :type The dialog type: :open, :save, or a custom string placed on the Ok button.
        Defaults to :open.
  :dir  The initial working directory. If omitted, the previous directory chosen
        is remembered and used.
  :multi?  If true, multi-selection is enabled and a seq of files is returned.
  :selection-mode The file selection mode: :files-only, :dirs-only and :files-and-dirs.
                  Defaults to :files-only
  :filters A seq of either:
             
             A seq that contains a filter name and a seq of
             extensions as strings for that filter.
             
             A seq that contains a filter name and a function 
             to be used as accept function. (see file-filter)

             A FileFilter. (see file-filter)

  :remember-directory? Flag specifying whether to remember the directory for future
                       file-input invocations in case of successful exit. Default: true.
  :success-fn  Function which will be called with the JFileChooser and the File which
               has been selected by the user. Its result will be returned.
               Default: return selected File. In the case of MULTI-SELECT? being true,
               a seq of File instances will be passed instead of a single File.
  :cancel-fn   Function which will be called with the JFileChooser on user abort of the dialog.
               Its result will be returned. Default: returns nil.

Examples:

  ; ask & return single file
  (choose-file)

  ; ask & return including a filter for image files
  (choose-file :filters [["Images" ["png" "jpeg"]
                         ["Folders" #(.isDirectory %)]
                         (file-filter "All files" (constantly true))]])

  ; ask & return absolute file path as string
  (choose-file :success-fn (fn [fc file] (.getAbsolutePath file)))

Returns result of SUCCESS-FN (default: either java.io.File or seq of java.io.File iff multi? set to true)
in case of the user selecting a file, or result of CANCEL-FN otherwise.

See http://download.oracle.com/javase/6/docs/api/javax/swing/JFileChooser.html


file-filter

function
Usage: (file-filter description accept)
Create a FileFilter.

Arguments:

  description - description of this filter, will show up in the
                filter-selection box when opening a file choosing dialog.

  accept - a function taking a java.awt.File
           returning true if the file should be shown,
           false otherwise.
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.