01: package org.uispec4j;
02:
03: import javax.swing.*;
04: import java.awt.*;
05:
06: /**
07: * Default implementation for the ListBoxCellValueConverter interface.
08: * Returns the text displayed by the renderer, only in the case of JLabel renderers -
09: * this method will return an empty String if the renderer is not a JLabel.
10: */
11: public class DefaultListBoxCellValueConverter implements
12: ListBoxCellValueConverter {
13: public String getValue(int index, Component renderedComponent,
14: Object modelObject) {
15: if (renderedComponent instanceof JLabel) {
16: return ((JLabel) renderedComponent).getText();
17: }
18: if (modelObject != null) {
19: return modelObject.toString();
20: }
21: return "";
22: }
23: }
|