1

I have the following java class called TimeBackUp.java that is the starting point for a javafx application:

 import javafx.application.Application;
 import static javafx.application.Application.launch;
 import javafx.geometry.Insets;
 import javafx.geometry.Pos;
 import javafx.scene.Scene;
 import javafx.scene.control.*;
 import javafx.scene.layout.*;
 import javafx.scene.media.AudioClip;
 import javafx.stage.Stage;

 public class TimeBackUp extends Application {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    launch(args);
}

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Time Backup");

    Button button = new Button("Button");
    VBox vertLayout = new VBox(10);
    HBox horLayout1 = new HBox(20);
    MenuBar mb = new MenuBar();
    vertLayout.getChildren().add(mb);
    final Menu backupMenu = new Menu("Backups");
    final MenuItem backupNow = new MenuItem("Backup Now");
    final MenuItem backupSett = new MenuItem("Schedule Backups");
    backupMenu.getItems().add(backupNow);
    backupMenu.getItems().add(backupSett);
    backupNow.setOnAction(actionEvent -> {

    });
    mb.getMenus().add(backupMenu);
    mb.getMenus().add(backupMenu);
    horLayout1.setPadding(new Insets(25.0));
    ComboBox<String> DateCb = new ComboBox<>();
    DateCb.setMinWidth(100);
    DateCb.getItems().add("Date 1");
    vertLayout.getChildren().add(horLayout1);
    Label lbl = new Label("Select A Backup to View the Files:");
    lbl.setPadding(new Insets(5, 0, 0, 0));
    horLayout1.getChildren().add(lbl);
    horLayout1.getChildren().add(DateCb);
    TreeItem root = new TreeItem("Sample Backup");
    TreeView<String> tree = new TreeView<>(root);

    for (int i = 0; i <1000;i++){
        TreeItemPath tip = new TreeItemPath(new PathNode(false,"file" + i,"num" +i ));
        root.getChildren().add(tip);
    }
    vertLayout.getChildren().add(tree);

    DateCb.setOnAction(actionEvent -> {
        System.out.println(DateCb.getValue());
    });

    Scene scene = new Scene(vertLayout, 700, 500);
    primaryStage.setScene(scene);
    primaryStage.show();
}

When ever I build my project I get the following error Note: /Users/yaakov/NetBeansProjects/TimeBackUp/src/timebackup/TimeBackUp.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

I have looked at the question and answers here "uses unchecked or unsafe operations" however I don't see anywhere in my code the problems that the answer in that question brings down.

Does anybody have any idea how to fix this error?

Community
  • 1
  • 1
SteelToe
  • 2,477
  • 1
  • 17
  • 28

1 Answers1

3

I solved it, The problem was that I declared a TreeItem without its generic type.

Meaning that instead of writing the proper TreeItem<String>; I just wrote plain TreeItem;.

SteelToe
  • 2,477
  • 1
  • 17
  • 28