-1

I'm having trouble with treetableview & jfoenix, and I've noticed that in my controller, it is not accepting Tournoi as type private JFXTreeTableView<Tournoi> Ttab;

I'm trying to retrieve data from the database and put the data into a treetableview, but I am getting compilation errors. Here is a class I'm using to access the database:

public class Tournoi {
private int id_tournoi;
private String nom;
private Date strat_date;
private Date end_date ;
private int reward1 ;
private int reward2;
private int reward3;
private int prix_par_joueur;
private int nbr_joueur;
private int etat;
private int id_compte;

public Tournoi(int id_tournoi, String nom, Date strat_date, Date end_date, int reward1, int reward2, int reward3, int prix_par_joueur, int nbr_joueur, int etat, int id_compte) {
    this.id_tournoi = id_tournoi;
    this.nom = nom;
    this.strat_date = strat_date;
    this.end_date = end_date;
    this.reward1 = reward1;
    this.reward2 = reward2;
    this.reward3 = reward3;
    this.prix_par_joueur = prix_par_joueur;
    this.nbr_joueur = nbr_joueur;
    this.etat = etat;
    this.id_compte = id_compte;
}




    public void addTournoi(Tournoi t) {
String req = "INSERT INTO `tournoi` ( `nom`, `start_date`, `end_date`, `reward1`, `reward2`, `reward3`, `prix_par_joueur`, `nbr_joueur`, `etat`, `id_compte`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
        try {
            ps = connection.prepareStatement(req);

            ps.setString(1, t.getNom());
            ps.setDate(2, (Date) t.getStrat_date());
            ps.setDate(3, (Date) t.getEnd_date());
            ps.setInt(4, t.getReward1());
            ps.setInt(5, t.getReward2());
            ps.setInt(6, t.getReward3());
            ps.setInt(7, t.getPrix_par_joueur());
            ps.setInt(8, t.getNbr_joueur());
            ps.setInt(9, t.getEtat());
            ps.setInt(10, t.getId_compte());

            ps.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

What could be the source of the problem?

devinbost
  • 4,658
  • 2
  • 44
  • 57
  • Please update your question with the stacktrace so we can see what is going wrong. – Hypnic Jerk Feb 09 '17 at 22:55
  • Hi, welcome to StackOverflow. I don't see any reference to your controller in the code you provided, so it's unclear where your issue is. Please provide that code to make it easier for others to help you troubleshoot your issue. – devinbost Feb 09 '17 at 23:08
  • this is the hole project : gameinjection.com/GameInjection1.zip – Garrach Achraf Feb 09 '17 at 23:15
  • What are the compilation errors? Which line(s) do they occur on? What imports are you using? – James_D Feb 10 '17 at 00:07
  • @MichaelPickett, he's experiencing a compile-time error, so he's not going to have a stacktrace. – devinbost Feb 10 '17 at 17:06

1 Answers1

0
  1. I don't see the jfoenix.jar file anywhere in your project. You need to include it or you won't get very far. Here's how to import a JAR file into IntelliJ IDEA. If you're using a different IDE, then you would need to lookup how to import a JAR using that IDE.
  2. It's missing the import import edu.esprit.gamehub.models.Tournoi; in the TournamentController class.
  3. After my import, I added this property to TournamentController:

    @FXML

    private com.jfoenix.controls.JFXTreeTableView<Tournoi> treeView;

It then gave me the error: Error:(33, 51) java: type argument edu.esprit.gamehub.models.Tournoi is not within bounds of type-variable S

  1. This caused me to recognize that the problem involves the way that you're using the bounded generic type.

Here's the top part of the JFXTreeTableView class:

public class JFXTreeTableView<S extends RecursiveTreeObject<S>> extends TreeTableView<S> {
    private TreeItem<S> originalRoot;
    private boolean itemWasSelected = false;
    private ObservableList<TreeTableColumn<S, ?>> groupOrder = FXCollections.observableArrayList();
    private Semaphore groupingSemaphore = new Semaphore(1);
    private Timer t;
    private ObjectProperty<Predicate<TreeItem<S>>> predicate;
    private IntegerProperty currentItemsCount;
    private Map<Object, Map<Object, ?>> groups;

    public JFXTreeTableView() {
        this.predicate = new SimpleObjectProperty(JFXTreeTableView$$Lambda$1.lambdaFactory$());
        this.currentItemsCount = new SimpleIntegerProperty(0);
        this.init();
    }

    public JFXTreeTableView(TreeItem<S> root, ObservableList<S> items) {
        super(root);
        this.predicate = new SimpleObjectProperty(JFXTreeTableView$$Lambda$2.lambdaFactory$());
        this.currentItemsCount = new SimpleIntegerProperty(0);
        this.originalRoot = root;
        this.init();
    }

Some example articles that address usage issues with generic types are:

The issue is that you're using a bounded type parameter, which has its own requirements. Your Tournoi class does not meet these requirements. To learn how to meet these requirements, please read:

Here's your clue: JFXTreeTableView<S extends RecursiveTreeObject<S>> extends TreeTableView<S>

What do you need your Tournoi class to inherit from to satisfy the requirements of the JFXTreeTableView generic class?

Community
  • 1
  • 1
devinbost
  • 4,658
  • 2
  • 44
  • 57