本文整理汇总了Java中javafx.scene.control.TableColumn.setText方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumn.setText方法的具体用法?Java TableColumn.setText怎么用?Java TableColumn.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TableColumn
的用法示例。
在下文中一共展示了TableColumn.setText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TableSample
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public TableSample() {
final ObservableList<Person> data = FXCollections.observableArrayList(
new Person("Jacob", "Smith", "[email protected]" ),
new Person("Isabella", "Johnson", "[email protected]" ),
new Person("Ethan", "Williams", "[email protected]" ),
new Person("Emma", "Jones", "[email protected]" ),
new Person("Michael", "Brown", "[email protected]" )
);
TableColumn firstNameCol = new TableColumn();
firstNameCol.setText("First");
firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
TableColumn lastNameCol = new TableColumn();
lastNameCol.setText("Last");
lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
TableColumn emailCol = new TableColumn();
emailCol.setText("Email");
emailCol.setMinWidth(200);
emailCol.setCellValueFactory(new PropertyValueFactory("email"));
TableView tableView = new TableView();
tableView.setItems(data);
tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
getChildren().add(tableView);
}
示例2: TableScrollSample
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public TableScrollSample() {
final ObservableList<Person> data = FXCollections.observableArrayList(
new Person("Jacob", "Smith", "[email protected]"),
new Person("Isabella", "Johnson", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"));
TableColumn firstNameCol = new TableColumn();
firstNameCol.setText("First");
firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
TableColumn lastNameCol = new TableColumn();
lastNameCol.setText("Last");
lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
TableColumn emailCol = new TableColumn();
emailCol.setText("Email");
emailCol.setMinWidth(200);
emailCol.setCellValueFactory(new PropertyValueFactory("email"));
TableView tableView = new TableView();
tableView.setItems(data);
ObservableList items = tableView.getItems();
for (int i = 0; i < 10; i++)
items.add(new Person("Name" + i, "Last" + i, "Email " + i));
tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
getChildren().add(tableView);
}
示例3: TaskSample
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public TaskSample() {
TableView<DailySales> tableView = new TableView<DailySales>();
Region veil = new Region();
veil.setStyle("-fx-background-color: rgba(0, 0, 0, 0.4)");
ProgressIndicator p = new ProgressIndicator();
p.setMaxSize(150, 150);
//Define table columns
TableColumn idCol = new TableColumn();
idCol.setText("ID");
idCol.setCellValueFactory(new PropertyValueFactory("dailySalesId"));
tableView.getColumns().add(idCol);
TableColumn qtyCol = new TableColumn();
qtyCol.setText("Qty");
qtyCol.setCellValueFactory(new PropertyValueFactory("quantity"));
tableView.getColumns().add(qtyCol);
TableColumn dateCol = new TableColumn();
dateCol.setText("Date");
dateCol.setCellValueFactory(new PropertyValueFactory("date"));
dateCol.setMinWidth(240);
tableView.getColumns().add(dateCol);
StackPane stack = new StackPane();
stack.getChildren().addAll(tableView, veil, p);
// Use binding to be notified whenever the data source chagnes
Task<ObservableList<DailySales>> task = new GetDailySalesTask();
p.progressProperty().bind(task.progressProperty());
veil.visibleProperty().bind(task.runningProperty());
p.visibleProperty().bind(task.runningProperty());
tableView.itemsProperty().bind(task.valueProperty());
getChildren().add(stack);
new Thread(task).start();
}
示例4: TableSample1
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public TableSample1() {
final ObservableList<Person> data = FXCollections.observableArrayList(
new Person("Jacob", "Smith", "[email protected]"),
new Person("Isabella", "Johnson", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"));
TableColumn firstNameCol = new TableColumn();
firstNameCol.setText("First");
firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
TableColumn lastNameCol = new TableColumn();
lastNameCol.setText("Last");
lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
TableColumn emailCol = new TableColumn();
emailCol.setText("Email");
emailCol.setMinWidth(200);
emailCol.setCellValueFactory(new PropertyValueFactory("email"));
TableView tableView = new TableView();
tableView.setItems(data);
tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
getChildren().add(tableView);
}
示例5: init
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private void init(Stage primaryStage) {
Group root = new Group();
primaryStage.setScene(new Scene(root));
VBox vbox = new VBox(5);
vbox.setPadding(new Insets(12));
TableView tableView = new TableView();
Button button = new Button("Refresh");
button.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
service.restart();
}
});
vbox.getChildren().addAll(tableView, button);
Region veil = new Region();
veil.setStyle("-fx-background-color: rgba(0, 800, 0, 0.3)");
ProgressIndicator p = new ProgressIndicator();
p.setMaxSize(150, 150);
//Define table columns
TableColumn idCol = new TableColumn();
idCol.setText("ID");
idCol.setMinWidth(150);
idCol.setCellValueFactory(new PropertyValueFactory<>("dailySalesId"));
tableView.getColumns().add(idCol);
TableColumn qtyCol = new TableColumn();
qtyCol.setText("Qty");
qtyCol.setMinWidth(150);
qtyCol.setCellValueFactory(new PropertyValueFactory<>("quantity"));
tableView.getColumns().add(qtyCol);
TableColumn dateCol = new TableColumn();
dateCol.setText("Date");
dateCol.setCellValueFactory(new PropertyValueFactory<>("date"));
dateCol.setMinWidth(150);
tableView.getColumns().add(dateCol);
p.progressProperty().bind(service.progressProperty());
veil.visibleProperty().bind(service.runningProperty());
p.visibleProperty().bind(service.runningProperty());
tableView.itemsProperty().bind(service.valueProperty());
StackPane stack = new StackPane();
stack.getChildren().addAll(vbox, veil, p);
root.getChildren().add(stack);
service.start();
}
示例6: ServiceSample
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public ServiceSample() {
VBox vbox = new VBox(5);
vbox.setPadding(new Insets(12));
TableView tableView = new TableView();
Button button = new Button("Refresh");
button.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
service.restart();
}
});
vbox.getChildren().addAll(tableView, button);
Region veil = new Region();
veil.setStyle("-fx-background-color: rgba(0, 0, 0, 0.4)");
ProgressIndicator p = new ProgressIndicator();
p.setMaxSize(150, 150);
//Define table columns
TableColumn idCol = new TableColumn();
idCol.setText("ID");
idCol.setCellValueFactory(new PropertyValueFactory("dailySalesId"));
tableView.getColumns().add(idCol);
TableColumn qtyCol = new TableColumn();
qtyCol.setText("Qty");
qtyCol.setCellValueFactory(new PropertyValueFactory("quantity"));
tableView.getColumns().add(qtyCol);
TableColumn dateCol = new TableColumn();
dateCol.setText("Date");
dateCol.setCellValueFactory(new PropertyValueFactory("date"));
dateCol.setMinWidth(240);
tableView.getColumns().add(dateCol);
p.progressProperty().bind(service.progressProperty());
veil.visibleProperty().bind(service.runningProperty());
p.visibleProperty().bind(service.runningProperty());
tableView.itemsProperty().bind(service.valueProperty());
StackPane stack = new StackPane();
stack.getChildren().addAll(vbox, veil, p);
getChildren().add(stack);
service.start();
}
示例7: loadScene
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Scene loadScene(){
VBox root = new VBox();
TableView<TesterMotorControl> motorsView = new TableView<TesterMotorControl>();
TableColumn<TesterMotorControl, String> nameCol = new TableColumn<TesterMotorControl, String>();
nameCol.setText("Name");
TableColumn<TesterMotorControl, Boolean> brakeCol = new TableColumn<TesterMotorControl, Boolean>();
brakeCol.setText("Brake Mode");
TableColumn<TesterMotorControl, Double> speedCol = new TableColumn<TesterMotorControl, Double>();
speedCol.setText("Speed");
TableColumn<TesterMotorControl, Double> voltageCol = new TableColumn<TesterMotorControl, Double>();
voltageCol.setText("Voltage");
TableColumn<TesterMotorControl, Double> currentCol = new TableColumn<TesterMotorControl, Double>();
currentCol.setText("Current");
nameCol.setCellValueFactory(new PropertyValueFactory<TesterMotorControl, String>("name"));
brakeCol.setCellValueFactory(new PropertyValueFactory<TesterMotorControl, Boolean>("brakeMode"));
speedCol.setCellValueFactory(new PropertyValueFactory<TesterMotorControl, Double>("speed"));
voltageCol.setCellValueFactory(new PropertyValueFactory<TesterMotorControl, Double>("voltage"));
currentCol.setCellValueFactory(new PropertyValueFactory<TesterMotorControl, Double>("current"));
motorsView.getColumns().addAll(nameCol, brakeCol, speedCol, voltageCol, currentCol);
keysBox = new ComboBox<String>();
VBox.setMargin(keysBox, new Insets(5.0, 0.0, 0.0, 0.0));
keysBox.getItems().add("-- Choose Tester --");
keysBox.getSelectionModel().select(0);
keysBox.getItems().addAll(TesterControl.getTestersNames());
keysBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue)->{
motorsView.getItems().clear();
if(tester != null){
tester.enable(false);
tester = null;
}
if(keysBox.getSelectionModel().selectedIndexProperty().get() == 0){
return;
}
tester = TesterControl.getTester(newValue);
if(tester == null){
keysBox.getSelectionModel().select(0);
return;
}
Enumeration<TesterMotorControl> motors = tester.getMotors();
for(; motors.hasMoreElements();)
motorsView.getItems().add(motors.nextElement());
tester.enable(true);
});
root.setSpacing(10);
root.setAlignment(Pos.CENTER);
root.getChildren().addAll(keysBox, motorsView);
return new Scene(root, 400, 245);
}