|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
javax.swing.DefaultListCellRenderer
uk.ac.starlink.util.gui.FileNameListCellRenderer
public class FileNameListCellRenderer
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).
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.DefaultListCellRenderer |
---|
DefaultListCellRenderer.UIResource |
Nested classes/interfaces inherited from class javax.swing.JLabel |
---|
JLabel.AccessibleJLabel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected static String |
ELLIPSIS
|
protected JComboBox |
parent
The JComboBox hosting these rendering instances, if used. |
Fields inherited from class javax.swing.DefaultListCellRenderer |
---|
noFocusBorder |
Fields inherited from class javax.swing.JLabel |
---|
labelFor |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
FileNameListCellRenderer()
Create an instance with default behaviour. |
|
FileNameListCellRenderer(JComboBox parent)
Create an instance that matches its width to that of a given JComboBox . |
Method Summary | |
---|---|
Component |
getListCellRendererComponent(JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
Return the requested component that renders the text. |
void |
paintComponent(Graphics g)
|
Methods inherited from class javax.swing.DefaultListCellRenderer |
---|
firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, invalidate, isOpaque, repaint, repaint, repaint, revalidate, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected JComboBox parent
protected static final String ELLIPSIS
Constructor Detail |
---|
public FileNameListCellRenderer()
public FileNameListCellRenderer(JComboBox parent)
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 Detail |
---|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
getListCellRendererComponent
in interface ListCellRenderer
getListCellRendererComponent
in class DefaultListCellRenderer
list
- the JList we're painting.value
- the value to assign to the cell. This should be a
a File
or String
.index
- the cell's index (not used).isSelected
- true if the specified cell was selected.cellHasFocus
- true if the specified cell has the focus.public void paintComponent(Graphics g)
paintComponent
in class JComponent
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |