streaming.gui.PaysComboBoxModel.java Source code

Java tutorial

Introduction

Here is the source code for streaming.gui.PaysComboBoxModel.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package streaming.gui;

import java.util.List;
import javax.swing.DefaultComboBoxModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import streaming.entity.Pays;
import streaming.service.PaysService;

/**
 *
 * @author ajc
 */
@Component
public class PaysComboBoxModel extends DefaultComboBoxModel<String> {

    @Autowired
    private PaysService paysService;

    private List<Pays> pays;

    public PaysComboBoxModel() {
    }

    public void setPays() {
        this.pays = paysService.rechercherTout();
    }

    public List<Pays> getPays() {
        return pays;
    }

    public Pays getPays(int index) {
        System.out.println(pays.get(index));
        return (Pays) pays.get(index);
    }

    @Override
    public String getElementAt(int index) {
        return pays.get(index).getNom();
    }

    @Override
    public int getSize() {
        return pays.size();
    }
}