fork download
  1. //fxml
  2.  
  3. <TableColumn text="Image" prefWidth="100">
  4. <cellValueFactory>
  5. <PropertyValueFactory property="image" />
  6. </cellValueFactory>
  7. <cellFactory>
  8. </cellFactory>
  9. </TableColumn>
  10.  
  11. //controller
  12. @FXML
  13. private void handleButtonActionSearch(ActionEvent event) {
  14.  
  15. image.setCellFactory(new
  16. Callback<TableColumn<BoardThread,BoardThread>,TableCell<BoardThread,BoardThread>>(){
  17.  
  18. @Override
  19. public TableCell<BoardThread, BoardThread> call(TableColumn<BoardThread, BoardThread> p) {
  20.  
  21. TableCell<BoardThread, BoardThread> cell = new TableCell<BoardThread, BoardThread>(){
  22.  
  23. @Override
  24. public void updateItem(BoardThread item, boolean empty) {
  25. if(item!=null){
  26. HBox box= new HBox();
  27. box.setSpacing(10) ;
  28. ImageView imageview = new ImageView();
  29. imageview.setFitHeight(50);
  30. imageview.setFitWidth(50);
  31. imageview.setImage(new Image("img/" + item.getImage()));
  32.  
  33. box.getChildren().addAll(imageview);
  34. //SETTING ALL THE GRAPHICS COMPONENT FOR CELL
  35. setGraphic(box);
  36. }
  37. }
  38. };
  39.  
  40. return cell;
  41. }
  42. });
  43. //model
  44.  
  45. public class BoardThread {
  46.  
  47. private final SimpleStringProperty image = new SimpleStringProperty("");
  48.  
  49.  
  50. public BoardThread() {
  51. this("");
  52. }
  53.  
  54. public BoardThread(String image) {
  55.  
  56. setImage(image);
  57.  
  58. }
  59.  
  60.  
  61. /* setting images */
  62.  
  63. public String getImage() {
  64. return image.get();
  65. }
  66.  
  67. public void setImage(String ffavoriteImage) {
  68. this.image.set(ffavoriteImage);
  69. }
  70.  
  71. }
  72.  
  73.  
  74.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: class, interface, or enum expected
 <TableColumn text="Image"  prefWidth="100">
 ^
Main.java:13: error: class, interface, or enum expected
    private void handleButtonActionSearch(ActionEvent event) {
            ^
Main.java:19: error: class, interface, or enum expected
        public TableCell<BoardThread, BoardThread> call(TableColumn<BoardThread, BoardThread> p) {
               ^
Main.java:24: error: class, interface, or enum expected
            public void updateItem(BoardThread item, boolean empty) {                        
                   ^
Main.java:27: error: class, interface, or enum expected
                    box.setSpacing(10) ;
                    ^
Main.java:28: error: class, interface, or enum expected
                    ImageView imageview = new ImageView();
                    ^
Main.java:29: error: class, interface, or enum expected
                    imageview.setFitHeight(50);
                    ^
Main.java:30: error: class, interface, or enum expected
                    imageview.setFitWidth(50);
                    ^
Main.java:31: error: class, interface, or enum expected
                    imageview.setImage(new Image("img/" + item.getImage())); 
                    ^
Main.java:33: error: class, interface, or enum expected
                    box.getChildren().addAll(imageview); 
                    ^
Main.java:35: error: class, interface, or enum expected
                    setGraphic(box);
                    ^
Main.java:36: error: class, interface, or enum expected
                }
                ^
Main.java:40: error: class, interface, or enum expected
            return cell;
            ^
Main.java:41: error: class, interface, or enum expected
        }
        ^
14 errors
stdout
Standard output is empty