class LanguageComboBoxRenderer extends JLabel implements ListCellRenderer<LanguageAdapter> {

  private static final Border BORDER = new EmptyBorder(1, 3, 1, 1);
  
  private final ResourceBundle messages;
  private final String extLangSuffix;

  LanguageComboBoxRenderer(ResourceBundle messages, String extLangSuffix) {
    super();
    setOpaque(true);
    setBorder(BORDER);
    this.messages = messages;
    this.extLangSuffix = extLangSuffix;
  }

  private String getTranslatedName(Language language) {
    String name = language.getTranslatedName(messages);
    if (language.isExternal()) {
      name += extLangSuffix;
    }
    return name;
  }

  @Override
  public Component getListCellRendererComponent(JList list, LanguageAdapter adapter, int index, boolean isSelected, boolean cellHasFocus) {<FILL_FUNCTION_BODY>}
}

    setComponentOrientation(list.getComponentOrientation());
    if (isSelected) {
      setBackground(list.getSelectionBackground());
      setForeground(list.getSelectionForeground());
    } else {
      setBackground(list.getBackground());
      setForeground(list.getForeground());
    }
    if (adapter != null) {
      Language lang = adapter.getLanguage();
      if (lang != null) {
        setText(getTranslatedName(lang));
        String langTag = lang.getLocaleWithCountryAndVariant().toLanguageTag();
        String country = lang.getLocaleWithCountryAndVariant().getCountry().toLowerCase();
        ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
        String filename = "flags/bytag/" + langTag + ".png";
        if (!dataBroker.resourceExists(filename)) {
          filename = "flags/" + country + ".png";
        }
        if (!dataBroker.resourceExists(filename)) {
          filename = "flags/empty.png";
        }
        ImageIcon icon = new ImageIcon(dataBroker.getFromResourceDirAsUrl(filename));
        setIcon(icon);
      } else {
        setText(adapter.getValue());
        setIcon(null);
      }
    }
    setEnabled(list.isEnabled());
    setFont(list.getFont());
    setBorder(BORDER);
    return this;
  
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(javax.swing.Icon) ,public void <init>(java.lang.String, int) ,public void <init>(javax.swing.Icon, int) ,public void <init>(java.lang.String, javax.swing.Icon, int) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.Icon getDisabledIcon() ,public int getDisplayedMnemonic() ,public int getDisplayedMnemonicIndex() ,public int getHorizontalAlignment() ,public int getHorizontalTextPosition() ,public javax.swing.Icon getIcon() ,public int getIconTextGap() ,public java.awt.Component getLabelFor() ,public java.lang.String getText() ,public javax.swing.plaf.LabelUI getUI() ,public java.lang.String getUIClassID() ,public int getVerticalAlignment() ,public int getVerticalTextPosition() ,public boolean imageUpdate(java.awt.Image, int, int, int, int, int) ,public void setDisabledIcon(javax.swing.Icon) ,public void setDisplayedMnemonic(int) ,public void setDisplayedMnemonic(char) ,public void setDisplayedMnemonicIndex(int) throws java.lang.IllegalArgumentException,public void setHorizontalAlignment(int) ,public void setHorizontalTextPosition(int) ,public void setIcon(javax.swing.Icon) ,public void setIconTextGap(int) ,public void setLabelFor(java.awt.Component) ,public void setText(java.lang.String) ,public void setUI(javax.swing.plaf.LabelUI) ,public void setVerticalAlignment(int) ,public void setVerticalTextPosition(int) ,public void updateUI() <variables>static final java.lang.String LABELED_BY_PROPERTY,private javax.swing.Icon defaultIcon,private javax.swing.Icon disabledIcon,private boolean disabledIconSet,private int horizontalAlignment,private int horizontalTextPosition,private int iconTextGap,protected java.awt.Component labelFor,private int mnemonic,private int mnemonicIndex,private java.lang.String text,private static final java.lang.String uiClassID,private int verticalAlignment,private int verticalTextPosition