import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
FormatInfo info = (FormatInfo)value;
Component comp = delegate.getListCellRendererComponent(list, info.getDisplayName(), index, isSelected, cellHasFocus);
if (comp instanceof JComponent) {
JComponent jcomp = (JComponent)comp;
Border border = jcomp.getBorder();
if ((border != null) && (border.getBorderInsets(panel) != null)) { // Issue 161997
panel.setBorder(border);
} else {
panel.setBorder(BorderFactory.createEmptyBorder());
}
panel.setOpaque(jcomp.isOpaque());
jcomp.setBorder(null);
}
panel.removeAll();
panel.setBackground(comp.getBackground());
// 1st column
comp.setPreferredSize(null);
Dimension prefSize = comp.getPreferredSize();
comp.setPreferredSize(new Dimension(width1, prefSize.height));
comp.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
panel.add(comp);
panel.add(Box.createHorizontalStrut(5));
// 2nd column
label.setText(info.getExample());
label.setForeground(comp.getForeground());
label.setFont(comp.getFont());
label.setPreferredSize(null);
prefSize = label.getPreferredSize();
label.setPreferredSize(new Dimension(width2, prefSize.height));
label.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
panel.add(label);
return panel;
}