Class FileNameListCellRenderer

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ListCellRenderer<Object>, SwingConstants

public class FileNameListCellRenderer extends DefaultListCellRenderer
FileNameListCellRenderer is a ListCellRenderer that displays a File or String truncated to the left, not right, so that the most meaningful parts of a file name are shown. For instance the string "/some/where/file.ext" could be rendered as ".../where/file.ext", depending on the component width.

This class can also make sure that the width of the JList associated with a JComboBox are matched (for long names JComboBoxes tend to just expand the drop-down JList to whatever size is needed, so if you're using this renderer with JComboBox you'll need to use this option).

Version:
$Id$
Author:
Peter W. Draper
See Also:
  • Field Details

    • parent

      protected JComboBox<?> parent
      The JComboBox hosting these rendering instances, if used.
    • ELLIPSIS

      protected static final String ELLIPSIS
      See Also:
  • Constructor Details

    • FileNameListCellRenderer

      public FileNameListCellRenderer()
      Create an instance with default behaviour.
    • FileNameListCellRenderer

      public FileNameListCellRenderer(JComboBox<?> parent)
      Create an instance that matches its width to that of a given JComboBox. When this is set the JList used as the drop-down menu can be made the same size (otherwise long names are allowed to extend past the visible right of the list).
  • Method Details