Created
January 19, 2022 13:37
-
-
Save Da9el00/ad9b99a818a4c519c18aebd90860c953 to your computer and use it in GitHub Desktop.
TableView Custom row hieghts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.collections.FXCollections; | |
import javafx.collections.ObservableList; | |
import javafx.fxml.FXML; | |
import javafx.fxml.Initializable; | |
import javafx.scene.control.ListView; | |
import javafx.scene.control.TableColumn; | |
import javafx.scene.control.TableView; | |
import javafx.scene.control.cell.PropertyValueFactory; | |
import java.net.URL; | |
import java.util.ResourceBundle; | |
public class HelloController implements Initializable { | |
@FXML | |
private TableView<Information> table; | |
@FXML | |
private TableColumn<Information, String> name; | |
@FXML | |
private TableColumn<Information, ListView> data; | |
ListView<String> listView = new ListView<String>(); | |
ObservableList<Information> info = FXCollections.observableArrayList( | |
new Information("test", listView), | |
new Information("test1", null) | |
); | |
@Override | |
public void initialize(URL url, ResourceBundle resourceBundle) { | |
name.setCellValueFactory(new PropertyValueFactory<Information, String>("name")); | |
data.setCellValueFactory(new PropertyValueFactory<Information, ListView>("data")); | |
listView.getItems().addAll("test","test2","test3"); | |
listView.setPrefHeight(80); | |
table.setItems(info); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.scene.control.ListView; | |
import javafx.scene.layout.VBox; | |
public class Information { | |
private String name; | |
private ListView data; | |
public Information(String name, ListView data) { | |
this.name = name; | |
this.data = data; | |
} | |
public String getName() { | |
return name; | |
} | |
public ListView getData() { | |
return data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment