001package jmri.profile; 002 003import java.awt.Component; 004import javax.swing.DefaultListCellRenderer; 005import javax.swing.JList; 006 007/** 008 * Implements a list cell renderer that provides a Profile-specific tool tip. 009 * 010 * @author Randall Wood (C) 2016 011 */ 012public class ProfileListCellRenderer extends DefaultListCellRenderer { 013 014 public ProfileListCellRenderer() { 015 } 016 017 @Override 018 public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 019 Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 020 if (-1 < index && null != value && value instanceof Profile) { 021 Profile profile = (Profile) value; 022 list.setToolTipText(Bundle.getMessage("ProfileTableModel.toolTip", profile.getName(), profile.getPath(), profile.getId(), "")); // NOI18N 023 } else { 024 list.setToolTipText(Bundle.getMessage("ProfileManagerDialog.profiles.toolTipText")); 025 } 026 return comp; 027 } 028 029}