filebot/source/net/sourceforge/tuned/ui/DefaultFancyListCellRendere...

76 lines
1.5 KiB
Java
Raw Normal View History

2008-03-22 21:12:34 +00:00
package net.sourceforge.tuned.ui;
import java.awt.Color;
import java.awt.Insets;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JList;
public class DefaultFancyListCellRenderer extends AbstractFancyListCellRenderer {
private final JLabel label = new JLabel();
public DefaultFancyListCellRenderer() {
add(label);
2008-03-22 21:12:34 +00:00
}
public DefaultFancyListCellRenderer(int padding) {
super(new Insets(padding, padding, padding, padding));
add(label);
2008-03-22 21:12:34 +00:00
}
protected DefaultFancyListCellRenderer(int padding, int margin, Color selectedBorderColor) {
2008-03-22 21:12:34 +00:00
super(new Insets(padding, padding, padding, padding), new Insets(margin, margin, margin, margin), selectedBorderColor);
add(label);
2008-03-22 21:12:34 +00:00
}
@Override
protected void configureListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.configureListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
label.setOpaque(false);
2008-03-22 21:12:34 +00:00
setText(value.toString());
}
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);
}
}
}