我正在尝试在 JavaFX 中执行以下操作:
TableView多行。Button当按下特定按钮时,TableView应该为每一行执行一些任务,一行接着另一行。(例如检查一些数据,...)ProgressIndicator“状态”列中应显示不确定,直到此行的任务完成,然后指示器显示为“已完成”。我在相关的 Stackoverflow 帖子和此处找到了一些帮助,并尝试根据需要进行调整,但遇到了一些问题:
ProgressIndicator当我运行程序时,每行的每个都会立即显示(不确定)。我怎样才能只激活它们/让它们在按下按钮后对每一行依次可见?我当前的可运行代码:
import java.util.Random;
import java.util.concurrent.*;
import javafx.application.Application;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Task;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import javafx.util.Callback;
public class ProgressIndicatorTableCellTest extends Application {
public void start(Stage primaryStage) {
TableView<TestTask> table = new TableView<>();
Random rng = new Random();
for (int i = 0; i …Run Code Online (Sandbox Code Playgroud) 为什么我得到“缺陷”而不是“正常”?
给定三个数字:A、B 和 H。据医生报告:
任务:
public class Main {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int units = input.nextInt();
int a = input.nextInt();
int b = input.nextInt();
int h = b - a;
if (h < a ){
System.out.println("Deficiency");
} else if (h > b) {
System.out.println("Excess");
} else if (h == 8){
System.out.println("Normal");
}
}
}
Run Code Online (Sandbox Code Playgroud) package com.ripal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
public class Outputs {
public void show() {
final ArrayList<String> list = new ArrayList<String>();
list.add("banana");
list.add("apple");
Iterator<String> itr = list.iterator();
Collections.sort(list);
while (itr.hasNext()) {
System.out.println(itr.next() + " ");
}
}
}
class Test {
public static void main(String[] args) {
Outputs outputs = new Outputs();
outputs.show();
}
}
Run Code Online (Sandbox Code Playgroud)