|
|||||||||
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.plaf.basic.BasicComboBoxRenderer
ikayaki.gui.FittedComboBoxRenderer
class FittedComboBoxRenderer
Fits the contents of a ComboBox list to a components width by shortening the text. Especially useful for showing long file paths in a narrow list.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicComboBoxRenderer |
---|
BasicComboBoxRenderer.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 | |
---|---|
private String |
delimiter
|
private String |
delimiterRegexp
|
private int |
fitLimit
|
private JComponent |
fitToComponent
|
Fields inherited from class javax.swing.plaf.basic.BasicComboBoxRenderer |
---|
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 | |
---|---|
FittedComboBoxRenderer(JComponent fitToComponent)
Creates a FittedComboBoxRenderer that will fit the list items to the width of a component. |
|
FittedComboBoxRenderer(JComponent fitToComponent,
String delimiter,
String regexp)
Creates a FittedComboBoxRenderer that will fit the list items to the width of a component. |
Method Summary | |
---|---|
int |
fitValue(Object value)
Fits the specified object to this component. |
int |
fitValue(Object value,
int fitLimit)
Fits the specified object to this component. |
int |
getFitLimit()
Returns the number of parts that will be chopped of the text, or -1 if it is being detected automatically. |
Component |
getListCellRendererComponent(JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
|
void |
setFitLimit(int fitLimit)
Sets the number of parts that should be chopped of the text. |
Methods inherited from class javax.swing.plaf.basic.BasicComboBoxRenderer |
---|
getPreferredSize |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private JComponent fitToComponent
private int fitLimit
private String delimiter
private String delimiterRegexp
Constructor Detail |
---|
public FittedComboBoxRenderer(JComponent fitToComponent)
fitToComponent
- the component to whose width the list items will be fit to.
NullPointerException
- if fitToComponent is null.public FittedComboBoxRenderer(JComponent fitToComponent, String delimiter, String regexp)
fitToComponent
- the component to whose width the list items will be fit to.delimiter
- the string with which to join the parts after they have been split.regexp
- a regular expression of the delimiter with which to split the text into parts.
NullPointerException
- if any of the parameters is null.Method Detail |
---|
public int getFitLimit()
public void setFitLimit(int fitLimit)
fitLimit
- a fixed number of parts to chop off, or -1 to detected it automatically.public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
getListCellRendererComponent
in interface ListCellRenderer
getListCellRendererComponent
in class BasicComboBoxRenderer
public int fitValue(Object value)
value
- the object whose toString() value to fit into this renderer component.
public int fitValue(Object value, int fitLimit)
value
- the object whose toString() value to fit into this renderer component.fitLimit
- the fixed number parts to chop off the value, or -1 to detect it automatically.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |