2

I can't display my Observable List in the table view. I don't get any error. I was check if Observable List and List have value and everything looks fine. I don't have any idea where is a problem. I was try to add ValueFactory also in FXML code and it still don't work

FXML
 <TableView fx:id="laczenie" layoutX="641.0" layoutY="52.0" prefHeight="415.0" prefWidth="438.0">
        <columns>
          <TableColumn prefWidth="75.0" text="Wezly" fx:id="C1" >
          </TableColumn>    
          <TableColumn prefWidth="361.0" text="MozliwePolaczenia" fx:id="C2">
          </TableColumn>
        </columns>
      </TableView>
JavaFx Controller 

public class FXMLDocumentController implements Initializable {
     private JavaFXApplication4 mainApp;
    public List<Krawendzie> list = new ArrayList<Krawendzie>();
     @FXML
    private TableColumn C1;
    @FXML
     private TableColumn C2;
    @FXML
    private TableView<Krawendzie> laczenie;
    @FXML
    private Label label;
    @FXML
    private ComboBox<String> combo;
    @FXML
    private GridPane Scena;
    @FXML
    private void handleButtonAction(ActionEvent event) {
        System.out.println("You clicked me!");
        label.setText("Hello World!");
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        C1.setCellValueFactory(new PropertyValueFactory<Krawendzie,Integer>("Wezel"));
        C2.setCellValueFactory(new PropertyValueFactory<Krawendzie,Integer>("Mozliwosci"));
        combo.getItems().addAll("2","3","4","5","6","7","8");
        list.removeAll(list);
    }
    @FXML
    private void itemselected(ActionEvent event){
    }


     @FXML
    private void rysuj(ActionEvent event) {
        rysuj2(Integer.parseInt(combo.getValue()));

    }
    private void rysuj2(Integer Ilosc){
        list.removeAll(list);
        Scena.getChildren().clear();
        laczenie = new TableView<Krawendzie>(); 
        File f = new File("././Image/Imapges1.jpg");
        Image image = new Image(f.toURI().toString());
        Integer ilosc = 0;
        for (int i = 0; i<=Ilosc;i++)
        {
            for(int k = 1;k<Scena.getColumnConstraints().size();k=k+2)
            {   
                if(k%2 != 0)
                {
                    Circle circle = new Circle(20, 20, 20);
                    circle.setFill(new ImagePattern(image));
                    Scena.add(circle,k,i);
                    list.add(new Krawendzie(ilosc,ilosc));
                    ilosc++;
                }
                if(ilosc == Ilosc)
                    break;
            }
        if(ilosc == Ilosc)
                break;
        }
        getData();
    }
      public void getData()
    {
        ObservableList<Krawendzie> obsList = FXCollections.observableArrayList(list);
        laczenie.setItems(obsList);
        //return obsList;
    }
}


And Main Application 


public class JavaFXApplication4 extends Application {

    @Override
    public void start(Stage stage) throws Exception {        
        Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show(); 
    }

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

}

1 Answer 1

0

sorry for question i have an answer. I only need to delete laczenie = new TableView(); because i was create a new object of talbeview so i can't work

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.