All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.ird.observe.client.util.ComboBoxListCellRenderer Maven / Gradle / Ivy

package fr.ird.observe.client.util;

/*-
 * #%L
 * ObServe Toolkit :: Common Client
 * %%
 * Copyright (C) 2008 - 2017 IRD, Ultreia.io
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 * Created by tchemit on 20/09/17.
 *
 * @author Tony Chemit - [email protected]
 */
public class ComboBoxListCellRenderer implements ListCellRenderer {

    private final ListCellRenderer renderer;

    public ComboBoxListCellRenderer(ListCellRenderer renderer) {
        this.renderer = renderer;
    }

    @Override
    public Component getListCellRendererComponent(JList list,
                                                  E value,
                                                  int index,
                                                  boolean isSelected,
                                                  boolean cellHasFocus) {
        Component comp = renderer.getListCellRendererComponent(
                list,
                value,
                index,
                isSelected,
                cellHasFocus
        );
        if (comp instanceof JLabel) {
            JLabel jcomp = (JLabel) comp;
            jcomp.setToolTipText(jcomp.getText());
        }
        return comp;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy