1

I am having a warning issue when I compile javafx program after use -Xlint (recommended by the same javac compiler) I noticed that this warning ocurre when I use TableView class component. I am using Java 1.8.073 and the warning message that I got is

warning: [rawtypes]  found raw type: TableView private TableView table  new TableView ();
missing type arguments for generic class TableView(S) where S is a type-variable: S extends Object declared in class TableView 

The code of my javafx program is code:

import javafx.application.Application;
import javafx.scene.control.Label;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.stage.Stage;
import javafx.scene.text.Font;
import javafx.scene.layout.*;

public class puntoventa extends Application {

    private TableView  table = new TableView();

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {
        stage.setWidth(500);
        stage.setHeight(500);

        table.setEditable(true);
        Label label = new Label("Alumnos");
        label.setFont(new Font("Arial", 20));
        TableColumn nombre = new TableColumn("Name");
        TableColumn edad = new TableColumn("Age");
        table.getColumns().addAll(nombre, edad );
        VBox vbox = new VBox(20, label, table);
        Scene scene = new Scene(vbox, 300, 500);
        stage.setScene(scene);
        stage.show();
    }
}

I don´t know what I am doing wrong. I think I am not using TableView correctly. I would like to remove that warning and I would like make my compilation right even the class is generated after compilation, thank you very much for your help, any help is appreciated

Omar

fabian
  • 80,457
  • 12
  • 86
  • 114
  • 1
    `TableView` and `TableColumn` are obviously declared raw. Add the type of object you want to add to the `items` list of the `TableView` as (first) type parameter. – fabian Dec 31 '18 at 00:23
  • 2
    See [What is a raw type and why shouldn't we use it?](https://stackoverflow.com/questions/2770321/). Unfortunately, the `ObservableList.addAll(Object...)` overload will still likely cause warnings even if you add the generic parameters to your `TableView` and `TableColumn` (see [Java generics and varargs](https://stackoverflow.com/questions/3096708)). – Slaw Dec 31 '18 at 00:51
  • i will continue working with javafx even if i have this warning, i can not remove that warning – Omar Elio Torres Castillo Jan 01 '19 at 01:51

0 Answers0