2008-03-22 17:12:34 -04:00
|
|
|
|
|
|
|
package net.sourceforge.tuned.ui;
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Color;
|
|
|
|
import java.awt.Insets;
|
|
|
|
|
2009-05-02 19:34:04 -04:00
|
|
|
import javax.swing.DefaultListCellRenderer;
|
2008-03-22 17:12:34 -04:00
|
|
|
import javax.swing.Icon;
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
import javax.swing.JList;
|
|
|
|
|
|
|
|
|
|
|
|
public class DefaultFancyListCellRenderer extends AbstractFancyListCellRenderer {
|
|
|
|
|
2009-05-02 19:34:04 -04:00
|
|
|
private final JLabel label = new DefaultListCellRenderer();
|
2008-03-22 17:12:34 -04:00
|
|
|
|
2011-11-27 09:39:58 -05:00
|
|
|
|
2008-03-22 17:12:34 -04:00
|
|
|
public DefaultFancyListCellRenderer() {
|
2008-10-11 16:42:03 -04:00
|
|
|
add(label);
|
2008-03-22 17:12:34 -04:00
|
|
|
}
|
2011-11-27 09:39:58 -05:00
|
|
|
|
2008-03-22 17:12:34 -04:00
|
|
|
|
|
|
|
public DefaultFancyListCellRenderer(int padding) {
|
|
|
|
super(new Insets(padding, padding, padding, padding));
|
2008-10-11 16:42:03 -04:00
|
|
|
add(label);
|
2008-03-22 17:12:34 -04:00
|
|
|
}
|
2011-11-27 09:39:58 -05:00
|
|
|
|
2009-07-01 12:14:21 -04:00
|
|
|
|
|
|
|
public DefaultFancyListCellRenderer(Insets padding) {
|
|
|
|
super(padding);
|
|
|
|
add(label);
|
|
|
|
}
|
2011-11-27 09:39:58 -05:00
|
|
|
|
2008-03-22 17:12:34 -04:00
|
|
|
|
2008-10-11 16:42:03 -04:00
|
|
|
protected DefaultFancyListCellRenderer(int padding, int margin, Color selectedBorderColor) {
|
2008-03-22 17:12:34 -04:00
|
|
|
super(new Insets(padding, padding, padding, padding), new Insets(margin, margin, margin, margin), selectedBorderColor);
|
2008-10-11 16:42:03 -04:00
|
|
|
add(label);
|
2008-03-22 17:12:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void configureListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
|
|
|
super.configureListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
2008-03-24 11:41:10 -04:00
|
|
|
label.setOpaque(false);
|
2008-10-19 08:44:55 -04:00
|
|
|
setText(String.valueOf(value));
|
2008-03-22 17:12:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setIcon(Icon icon) {
|
|
|
|
label.setIcon(icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setText(String text) {
|
|
|
|
label.setText(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setHorizontalTextPosition(int textPosition) {
|
|
|
|
label.setHorizontalTextPosition(textPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setVerticalTextPosition(int textPosition) {
|
|
|
|
label.setVerticalTextPosition(textPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setForeground(Color fg) {
|
|
|
|
super.setForeground(fg);
|
|
|
|
|
|
|
|
// label is null while in super constructor
|
|
|
|
if (label != null) {
|
|
|
|
label.setForeground(fg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|