TableView table = new TableView<Object>();
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
TableColumn column = new TableColumn("asda");
table.getColumns().add(column);
FXMLLoader loader = new FXMLLoader(getClass().getResource("com/blablabla/Some.fxml"));
FXMLLoader loader = new FXMLLoader(getClass().getResource("/com/blablabla/Some.fxml"));
if (contact == null){
lblName.setText(contact.getName());
lblSense.setText(contact.getSense());
}
if ( empty||contact == null){
setText(null);
setGraphic(null);
}
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Pane root = new Pane();
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
//подготавливаем список для листа
ObservableList<TestEntity> list = FXCollections.<TestEntity>observableArrayList();
list.addAll(
new TestEntity(new Button("button1"), "str1"),
new TestEntity(new Button("button2"), "str2"),
new TestEntity(new Button("button3"), "str3"));
ListView<TestEntity> listView = new ListView<TestEntity>(list);
//устанавливаем фабрику для отрисовки ячейки.
listView.setCellFactory(new Callback<ListView<TestEntity>, ListCell<TestEntity>>() {
@Override
public ListCell<TestEntity> call(ListView<TestEntity> param) {
//тут нужно собрать объект ListCell, и вернуть его
ListCell<TestEntity> listCell = new ListCell<TestEntity>(){
//отрисовка происходит здеся
@Override
protected void updateItem(TestEntity item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
setGraphic(null);
} else {
//тут конструируешь все что захочешь
//или можешь подгружать fxml
HBox hBox = new HBox();
Label label = new Label(item.getString());
hBox.getChildren().addAll(item.getButton(), label);
//устанавливаем графику
setGraphic(hBox);
}
}
};
return listCell;
}
});
root.getChildren().add(listView);
}
class TestEntity{
Button button;
String string;
TestEntity(Button button, String str){
setButton(button);
setString(str);
}
public Button getButton() {
return button;
}
public void setButton(Button button) {
this.button = button;
}
public String getString() {
return string;
}
public void setString(String string) {
this.string = string;
}
}
public static void main(String[] args) {
launch(args);
}
}
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
* Created by Evgeny on 18.03.2016.
*/
public class Example extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane borderPane = new BorderPane();
SplitPane splitPane1 = new SplitPane();
Button button_changeContainer = new Button("Изменить контейнер");
splitPane1.getItems().add(button_changeContainer);
SplitPane splitPane2 = new SplitPane();
splitPane2.getItems().addAll(new Label("Первый"),new Label("Контейнер"), new Label("SplitPane"));
VBox vBox = new VBox();
vBox.getChildren().addAll(new Label("Второй"),new Label("Контейнер"), new Label("VBox"));
borderPane.setCenter(splitPane1);
borderPane.setRight(splitPane2);
button_changeContainer.setOnAction(new EventHandler<ActionEvent>() {
boolean firstOrSecond = true;
@Override
public void handle(ActionEvent event) {
firstOrSecond = !firstOrSecond;
if(firstOrSecond){
borderPane.setRight(splitPane2);
}
else borderPane.setRight(vBox);
}
});
primaryStage.setScene(new Scene(borderPane));
primaryStage.setWidth(600);
primaryStage.setHeight(600);
primaryStage.show();
}
}
<link rel="stylesheet" type="text/css" href="style.css">
webEngine.load(FXMLController.class.getResource("/html/index.html").toExternalForm());
try {
webEngine.load(new File("html/index.html").toURI().toURL().toExternalForm());
} catch (IOException e) {
e.printStackTrace();
}