Skip to main content

Class JtvDirListBox

public class JtvDirListBox
extends JtvListBox

A list box that displays a hierarchical directory tree.

TDirListBox shows the directory tree of the current disk, with the path from the root to the current directory highlighted. Subdirectories of the current directory's parent are also shown, allowing the user to navigate by selecting items.

When the user selects an entry, a cmChangeDir command event is posted with the selected JtvDirEntry as the info pointer, allowing the owner dialog (typically JtvChangeDirDialog) to change to that directory.

Passing the special string "Drives" to newDirectory(String) switches the list to show the available disk drives instead of a directory tree.

org.viktor44.jtvision.dialogs.JtvDirListBox

Summary​

Constructors​

VisibilitySignature
publicJtvDirListBox(JtvRect bounds, JtvScrollBar aScrollBar)

Fields​

ModifiersField nameType
private static finalpathDirString
private static finalfirstDirString
private static finalmiddleDirString
private static finallastDirString
private static finaldrivesString
private finalentriesList<org.viktor44.jtvision.dialogs.JtvDirEntry>
privatedirString
privatecurint

Methods​

ModifiersMethod signatureReturn type
publicgetText(int item, int maxLen)String
publicisSelected(int item)boolean
publicselectItem(int item)void
publiclist()List<org.viktor44.jtvision.dialogs.JtvDirEntry>
publicnewDirectory(String str)void
privateshowDrives(List<org.viktor44.jtvision.dialogs.JtvDirEntry> dirs)void
privateshowDirs(List<org.viktor44.jtvision.dialogs.JtvDirEntry> dirs)void
publicsetState(int nState, boolean enable)void

Constructors​

JtvDirListBox(JtvRect bounds, JtvScrollBar aScrollBar)​

Creates an empty directory list box with the given bounds and scroll bar.

Parameters

  • bounds - the bounding rectangle
  • aScrollBar - the vertical scroll bar

Fields​

String pathDir​

Prefix string for items on the path from root to the current directory.

String firstDir​

Prefix for the first drive entry when showing the drives list.

String middleDir​

Prefix for middle entries in the drives list.

String lastDir​

Prefix for the last entry in the drives list.

String drives​

Special directory name that causes newDirectory(String) to list drives.

List<org.viktor44.jtvision.dialogs.JtvDirEntry> entries​

The JtvDirEntry objects currently displayed (parallel to the string list).

String dir​

The absolute path of the directory currently reflected in the list.

int cur​

The index within entries of the currently selected (active) directory.

Methods​

getText(int item, int maxLen)​

Overrides:

getText(int item, int maxLen) in org.viktor44.jtvision.dialogs.JtvListBox

Returns the display text for the entry at position item, truncated to maxLen characters.

Parameters

  • item - the zero-based item index
  • maxLen - the maximum number of characters to return

Returns

the entry's display text

isSelected(int item)​

Returns true if item item is the currently active directory (i.e., item == cur).

Parameters

  • item - the zero-based item index

Returns

true if this is the selected (current) directory

selectItem(int item)​

Posts a cmChangeDir command event with the JtvDirEntry at item as the payload, requesting that the owner changes to that directory.

Parameters

  • item - the zero-based item index to navigate to

list()​

Returns the list of JtvDirEntry objects currently displayed.

Returns

the entry list

newDirectory(String str)​

Populates the list with the directory tree for the given path, or with drive letters if str equals "Drives".

After loading, the list scrolls to the entry for the current directory.

Parameters

  • str - the absolute path of the directory to display, or null to use the JVM's current working directory

showDrives(List<org.viktor44.jtvision.dialogs.JtvDirEntry> dirs)​

Populates dirs with the available disk drive roots. The first entry is a "Drives" header; subsequent entries are the root paths.

Parameters

  • dirs

showDirs(List<org.viktor44.jtvision.dialogs.JtvDirEntry> dirs)​

Populates dirs with the directory tree from the filesystem root down to the current directory, followed by the siblings of the current directory. Sets cur to the index of the current directory's entry.

Parameters

  • dirs

setState(int nState, boolean enable)​

Extends the inherited setState to toggle the Chdir button's default state in the owning JtvChangeDirDialog when this list receives or loses focus.

Parameters

  • nState - the state flag(s) being changed
  • enable - true to set, false to clear