
no.tornado.databinding.model.PropertyListCellRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of databinding Show documentation
Show all versions of databinding Show documentation
Swing Data Binding is a powerful, fast, light and simple data binding framework for Java.
The newest version!
package no.tornado.databinding.model;
import no.tornado.databinding.Binding;
import javax.swing.*;
import java.awt.*;
public class PropertyListCellRenderer extends DefaultListCellRenderer {
private String propertyExpression;
public PropertyListCellRenderer(String propertyExpression) {
this.propertyExpression = propertyExpression;
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
return super.getListCellRendererComponent(list, value == null ? null : getPropertyValue(value), index, isSelected, cellHasFocus);
}
private Object getPropertyValue(Object value) {
try {
return Binding.propertyUtils.getNestedProperty(value, propertyExpression);
} catch (Exception e) {
e.printStackTrace();
return "Failed to get " + propertyExpression;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy