- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 JavaFX 应用程序计算另一个文件夹下一层的每个文件夹的大小。我的问题是,当我点击“应用”按钮(该按钮在另一个类中开始计算)时,我想要一个不确定的进度指示器来向用户显示该应用程序正在运行并且尚未自行挂起。默认情况下,进度指示器设置为不可见,仅在计算期间设置为可见。不幸的是,当我调用它时它没有出现。我不确定,但是当计算完成并将其中的数据设置为 JavaFX.Pie-Chart 时,我可能已经瞥见了该指标。
我已经尝试将指示器设置为默认可见,并简单地用新的矩形覆盖它,但这也不起作用。
Controller :
package sample;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.chart.PieChart;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Rectangle;
import javafx.stage.DirectoryChooser;
import javafx.stage.Stage;
import javafx.util.Duration;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
public class Controller {
@FXML
private PieChart pieChart;
@FXML
private TextField pathField;
@FXML
private Label subfolder;
@FXML
private Button up;
@FXML
private Button hide;
@FXML
private Button showHidden;
@FXML
private VBox field1;
@FXML
private VBox field2;
@FXML
private VBox field3;
@FXML
private VBox field4;
@FXML
private AnchorPane parentContainer;
@FXML
private ProgressIndicator loading;
private ObservableList<PieChart.Data> pieChartData;
private Calc calc;
public File directory;
String[] unit = {"Bytes", "KB", "MB", "GB", "TB", "PB", "ZB", "EB"};
int units = 0;
boolean hideSegment = false;
String[] hiddenPath = new String[500];
double[] hiddenSize = new double[500];
int Stelle = 499;
boolean first = true;
@FXML
void initialize(){
pieChartData = FXCollections.observableArrayList();
calc = new Calc(pieChartData);
updataLabads();
pieChart.setData(pieChartData);
}
@FXML
private void handleBrowse(){
Stage stage = new Stage();
final DirectoryChooser dirChooser = new DirectoryChooser();
directory = dirChooser.showDialog(stage);
if(directory != null){
pathField.setText(directory.toString());
}
}
@FXML
private void apply(){
loading.setVisible(true);
directory = Paths.get(pathField.getText()).toFile();
if(directory!=null){
pieChartData.clear();
String strings = new String(pathField.getText());
calc.calcSubfoldersSize(strings);
updataLabads();
}
loading.setVisible(false);
}
public void updataLabads(){
pieChart.getData().forEach(data -> {
data.getNode().addEventHandler(MouseEvent.MOUSE_ENTERED, e -> {
for(int i=0;(data.getPieValue()/(Math.pow(1024, i))) > 1000;i++){
//System.out.println(i);
units = i+1;
}
subfolder.setText(data.getName() + ", " + Math.round(data.getPieValue()/(Math.pow(1024,units))) + " " + unit[units]);
//System.out.println(Math.round(data.getPieValue()/(Math.pow(1024,units))) + " " + unit[units]);
});
});
pieChart.getData().forEach(data -> {
data.getNode().addEventHandler(MouseEvent.MOUSE_RELEASED, e -> {
if(hideSegment == false){
pathField.setText(pathField.getText() + "\\" + data.getName());
apply();
}else if(hideSegment == true){
pieChartData.remove(data);
hideSegment = false;
if(first == true){
first = false;
Stelle = 0;
}
hiddenPath[Stelle] = data.getName();
hiddenSize[Stelle] = data.getPieValue();
System.out.println("Hidden Variables have been updatet on Port " + Stelle);
Stelle++;
pieChart.setData(pieChartData);
}
});
});
}
@FXML
private void up(){
while(!pathField.getText().substring(pathField.getText().length()-1).equals("\\")){
pathField.setText(pathField.getText().substring(0, pathField.getText().length()-1));
}
pathField.setText(pathField.getText().substring(0, pathField.getText().length()-1));
apply();
}
@FXML
public void hide(){
if(hideSegment == false)hideSegment = true;
else if(hideSegment == true)hideSegment = false;
}
@FXML
public void showHidden(){
System.out.println("Tried to load HiddenVariables on Port " + (Stelle-1));
System.out.println(hiddenPath[Stelle-1] + " " + hiddenSize[Stelle-1]);
if(!hiddenPath[Stelle-1].equals(null)){
for(int i=Stelle; i!=0; i--){
pieChartData.add(new PieChart.Data(hiddenPath[Stelle-1], hiddenSize[Stelle-1]));
hiddenPath[Stelle-1] = "";
hiddenSize[Stelle-1] = 0;
Stelle--;
pieChart.setData(pieChartData);
updataLabads();
}
}
}
@FXML
public void Home() throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("Home.fxml"));
Scene scene = up.getScene();
root.translateYProperty().set(scene.getHeight());
parentContainer.getChildren().add(root);
Timeline timeline = new Timeline();
KeyValue kv = new KeyValue(root.translateYProperty(), 0 , Interpolator.EASE_BOTH);
KeyFrame kf = new KeyFrame(Duration.seconds(.5), kv);
timeline.getKeyFrames().add(kf);
timeline.play();
parentContainer.getChildren().remove(parentContainer);
}
@FXML
public void Files(){}
@FXML
public void Settings(){}
@FXML
public void Close(){
Platform.exit();
}
}
fxml文档:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.chart.PieChart?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ProgressIndicator?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.SVGPath?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="parentContainer" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="1000.0" style="-fx-background-color: #2A2E37;" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
<children>
<HBox prefHeight="600.0" prefWidth="1000.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<VBox alignment="CENTER" prefHeight="600.0" prefWidth="858.0" />
</children>
</HBox>
<PieChart fx:id="pieChart" layoutX="-341.0" layoutY="37.0" legendVisible="false" prefHeight="500.0" prefWidth="2000.0" stylesheets="@pieChart.css" />
<Label layoutX="620.0" layoutY="24.0" text="Subfolders" textFill="#b2b2b2">
<font>
<Font size="24.0" />
</font>
</Label>
<Label fx:id="subfolder" alignment="CENTER" layoutX="374.0" layoutY="551.0" prefHeight="26.0" prefWidth="584.0" textFill="#b2b2b2">
<font>
<Font size="25.0" />
</font>
</Label>
<HBox maxHeight="1.7976931348623157E308" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="100.0" prefWidth="320.0">
<children>
<VBox prefHeight="200.0" prefWidth="20.0">
<children>
<HBox minHeight="-Infinity" prefHeight="320.0" prefWidth="200.0" style="-fx-background-color: #353841;" />
<HBox minHeight="-Infinity" prefHeight="280.0" prefWidth="200.0" style="-fx-background-color: #3F434B;" />
</children>
</VBox>
<VBox minHeight="-Infinity" prefHeight="600.0" prefWidth="280.0">
<children>
<VBox prefHeight="604.0" prefWidth="280.0">
<children>
<VBox style="-fx-background-color: #353841;">
<children>
<HBox prefHeight="50.0" prefWidth="280.0">
<children>
<Label fx:id="label" alignment="BOTTOM_CENTER" contentDisplay="CENTER" prefHeight="64.0" prefWidth="280.0" text="Options" textAlignment="CENTER" textFill="#b2b2b2">
<font>
<Font size="28.0" />
</font>
</Label>
</children>
</HBox>
<HBox prefHeight="64.0" prefWidth="200.0">
<children>
<HBox alignment="CENTER" minWidth="-Infinity" prefHeight="64.0" prefWidth="195.0">
<children>
<TextField fx:id="pathField" focusTraversable="false" prefHeight="48.0" prefWidth="175.0" promptText="Type Path or:" stylesheets="@textField.css" />
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
<children>
<Button fx:id="browse" mnemonicParsing="false" onAction="#handleBrowse" prefHeight="48.0" prefWidth="68.0" stylesheets="@FXbuttons.css" text="Browse" />
</children>
</HBox>
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="64.0" prefWidth="200.0">
<children>
<Button fx:id="apply" mnemonicParsing="false" onAction="#apply" prefHeight="48.0" prefWidth="262.0" stylesheets="@FXbuttons.css" text="Apply" />
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="64.0" prefWidth="200.0">
<children>
<Button fx:id="up" mnemonicParsing="false" onAction="#up" prefHeight="48.0" prefWidth="262.0" stylesheets="@FXbuttons.css" text="Up" />
</children>
</HBox>
<HBox prefHeight="78.0" prefWidth="200.0">
<children>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
<children>
<Button fx:id="hide" mnemonicParsing="false" onAction="#hide" prefHeight="48.0" prefWidth="124.0" stylesheets="@FXbuttons.css" text="Hide" />
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
<children>
<Button fx:id="showHidden" mnemonicParsing="false" onAction="#showHidden" prefHeight="48.0" prefWidth="124.0" stylesheets="@FXbuttons.css" text="Show hidden" />
</children>
</HBox>
</children>
</HBox>
</children>
</VBox>
<VBox prefHeight="280.0" prefWidth="100.0" style="-fx-background-color: #3F434B;">
<children>
<HBox prefHeight="140.0" prefWidth="200.0">
<children>
<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onMouseClicked="#Home" prefHeight="140.0" prefWidth="140.0" styleClass="vbox" stylesheets="@fields.css">
<children>
<SVGPath content="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" fill="#4a4d55" scaleX="2.44" scaleY="2.44" />
</children>
</VBox>
<VBox id="VBox" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onMouseClicked="#Files" prefHeight="140.0" prefWidth="140.0" styleClass="VBox" stylesheets="@fields.css">
<children>
<SVGPath content="M11 2v20c-5.07-.5-9-4.79-9-10s3.93-9.5 9-10zm2.03 0v8.99H22c-.47-4.74-4.24-8.52-8.97-8.99zm0 11.01V22c4.74-.47 8.5-4.25 8.97-8.99h-8.97z" fill="#4a4d55" scaleX="2.44" scaleY="2.44" />
</children>
</VBox>
</children>
</HBox>
<HBox prefHeight="140.0" prefWidth="200.0">
<children>
<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onMouseClicked="#Settings" prefHeight="140.0" prefWidth="140.0" stylesheets="@locked.css">
<children>
<SVGPath content="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2zM18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z" fill="#4a4d55" scaleX="2.88" scaleY="2.88" styleClass="icon-settings" />
</children>
</VBox>
<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onMouseClicked="#Close" prefHeight="140.0" prefWidth="140.0" stylesheets="@fields.css">
<children>
<SVGPath content="M13 3h-2v10h2V3zm4.83 2.17l-1.42 1.42C17.99 7.86 19 9.81 19 12c0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.19 1.01-4.14 2.58-5.42L6.17 5.17C4.23 6.82 3 9.26 3 12c0 4.97 4.03 9 9 9s9-4.03 9-9c0-2.74-1.23-5.18-3.17-6.83z" fill="#4a4d55" scaleX="2.44" scaleY="2.44" />
</children>
</VBox>
</children>
</HBox>
</children>
</VBox>
</children>
</VBox>
</children>
</VBox>
<VBox minWidth="-Infinity" prefHeight="200.0" prefWidth="20.0">
<children>
<HBox minHeight="-Infinity" prefHeight="320.0" prefWidth="200.0" style="-fx-background-color: #353841;" />
<HBox minHeight="-Infinity" prefHeight="280.0" prefWidth="200.0" style="-fx-background-color: #3F434B;" />
</children>
</VBox>
</children>
</HBox>
<ProgressIndicator fx:id="loading" layoutX="627.0" layoutY="250.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="100.0" prefWidth="100.0" visible="false" />
</children>
</AnchorPane>
计算类:
package sample;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import javafx.collections.ObservableList;
import javafx.scene.chart.PieChart;
public class Calc {
private int totalFolder=0, totalFile=0;
private static int counter = 0;
private final ObservableList<PieChart.Data> pieChartData;
private long filesInRoot = 0;
Path fileInRoot;
//added a constructor to receive a reference of the Observable list
public Calc(ObservableList<PieChart.Data> pieChartData) {
this.pieChartData = pieChartData;
}
public void calcSubfoldersSize(String sPath) { //replaces public void main(String args)
File nativeFile = new File(sPath);
File file = new File(nativeFile.toString());
String[] files = file.list();
Path path;
filesInRoot = 0;
if(file.isDirectory()) {
for(int i=0; i<=files.length-1; i++) {
path = Paths.get(files[i]);
file = path.toFile();
counter ++;
}
String[] paths = new String[counter];
for(int i=0; i<=files.length-1; i++) {
path = Paths.get(files[i]);
file = path.toFile();
paths[i] = file.toString();
}
for(int i=0; i!=counter; i++) {
}
for(int i = 0; i+1 <= paths.length; i++) {
try {
Calc size = new Calc(pieChartData); //the only line changed in the method
long fileSizeByte = size.getFileSize(new File(nativeFile.toString() + "\\" + paths[i]));
add(paths[i],fileSizeByte,i,paths.length);
} catch (Exception e) {
fileInRoot = Paths.get(nativeFile.toString()+"\\" + paths[i]);
filesInRoot = filesInRoot + fileInRoot.toFile().length();
}
}
if(filesInRoot!=0){
pieChartData.add(new PieChart.Data("Files in Directory",filesInRoot));
System.out.println(filesInRoot);
}
}
}
//let add update the observable list
public void add(String loc, long size, int i, int aim){
pieChartData.add(new PieChart.Data(loc,size));
}
public long getFileSize(File folder) {
long foldersize = 0;
totalFolder++;
// System.out.println("Folder: " + folder + " (Source: getFileSize)");
File[] filelist = folder.listFiles();
// System.out.println(folder.listFiles());
for (int i = 0; i < filelist.length; i++) {
if (filelist[i].isDirectory()) {
foldersize += getFileSize(filelist[i]);
} else {
totalFile++;
foldersize += filelist[i].length();
}
}
return foldersize;
}
public int getTotalFolder() {
return totalFolder;
}
public int getTotalFile() {
return totalFile;
}
}
编辑:
主类:
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("Files.fxml"));
primaryStage.setTitle("Fileview.io");
primaryStage.setScene(new Scene(root));
primaryStage.setResizable(false);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Controller 类:
package sample;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.chart.PieChart;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Rectangle;
import javafx.stage.DirectoryChooser;
import javafx.stage.Stage;
import javafx.util.Duration;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
public class Controller {
@FXML
private PieChart pieChart;
@FXML
private TextField pathField;
@FXML
private Label subfolder;
@FXML
private Button up;
@FXML
private Button hide;
@FXML
private Button showHidden;
@FXML
private VBox field1;
@FXML
private VBox field2;
@FXML
private VBox field3;
@FXML
private VBox field4;
@FXML
private AnchorPane parentContainer;
@FXML
private ProgressIndicator loading;
private ObservableList<PieChart.Data> pieChartData;
private Calc calc;
public File directory;
String[] unit = {"Bytes", "KB", "MB", "GB", "TB", "PB", "ZB", "EB"};
int units = 0;
boolean hideSegment = false;
String[] hiddenPath = new String[500];
double[] hiddenSize = new double[500];
int Stelle = 499;
boolean first = true;
@FXML
private void handleBrowse(){
Stage stage = new Stage();
final DirectoryChooser dirChooser = new DirectoryChooser();
directory = dirChooser.showDialog(stage);
if(directory != null){
pathField.setText(directory.toString());
}
}
@FXML
private void apply() {
loading.setVisible(true);
Task<Void> applyTask = new Task<Void>() {
@Override
protected Void call() throws Exception {
Thread.sleep(0);//sleep for 10 seconds just to show that the progress indicator is working
directory = Paths.get(pathField.getText()).toFile();
if (directory != null) {
//fx-parts need to be executed by Platform.runLater(...)
Platform.runLater(() -> pieChartData.clear());
String strings = new String(pathField.getText());
calc.calcSubfoldersSize(strings);
//again let fx-parts be executed in the fx-application-thread
Platform.runLater(() -> updataLabads());
}
return null;
}
};
applyTask.setOnSucceeded(e -> loading.setVisible(false));
applyTask.setOnFailed(e -> loading.setVisible(false));//handle error here...
new Thread(applyTask, "Apply thread").start();
//loading.setVisible(false); //done when the task ends
}
public void updataLabads(){
pieChart.getData().forEach(data -> {
data.getNode().addEventHandler(MouseEvent.MOUSE_ENTERED, e -> {
for(int i=0;(data.getPieValue()/(Math.pow(1024, i))) > 1000;i++){
//System.out.println(i);
units = i+1;
}
subfolder.setText(data.getName() + ", " + Math.round(data.getPieValue()/(Math.pow(1024,units))) + " " + unit[units]);
//System.out.println(Math.round(data.getPieValue()/(Math.pow(1024,units))) + " " + unit[units]);
});
});
pieChart.getData().forEach(data -> {
data.getNode().addEventHandler(MouseEvent.MOUSE_RELEASED, e -> {
if(hideSegment == false){
pathField.setText(pathField.getText() + "\\" + data.getName());
apply();
}else if(hideSegment == true){
pieChartData.remove(data);
hideSegment = false;
if(first == true){
first = false;
Stelle = 0;
}
hiddenPath[Stelle] = data.getName();
hiddenSize[Stelle] = data.getPieValue();
System.out.println("Hidden Variables have been updatet on Port " + Stelle);
Stelle++;
pieChart.setData(pieChartData);
}
});
});
}
@FXML
private void up(){
while(!pathField.getText().substring(pathField.getText().length()-1).equals("\\")){
pathField.setText(pathField.getText().substring(0, pathField.getText().length()-1));
}
pathField.setText(pathField.getText().substring(0, pathField.getText().length()-1));
apply();
}
@FXML
public void hide(){
if(hideSegment == false)hideSegment = true;
else if(hideSegment == true)hideSegment = false;
}
@FXML
public void showHidden(){
System.out.println("Tried to load HiddenVariables on Port " + (Stelle-1));
System.out.println(hiddenPath[Stelle-1] + " " + hiddenSize[Stelle-1]);
if(!hiddenPath[Stelle-1].equals(null)){
for(int i=Stelle; i!=0; i--){
pieChartData.add(new PieChart.Data(hiddenPath[Stelle-1], hiddenSize[Stelle-1]));
hiddenPath[Stelle-1] = "";
hiddenSize[Stelle-1] = 0;
Stelle--;
pieChart.setData(pieChartData);
updataLabads();
}
}
}
public void initialize(){
pieChartData = FXCollections.observableArrayList();
updataLabads();
calc = new Calc(pieChartData);
pieChart.setData(pieChartData);
}
@FXML
public void Home() throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("Home.fxml"));
Scene scene = up.getScene();
root.translateYProperty().set(scene.getHeight());
parentContainer.getChildren().add(root);
Timeline timeline = new Timeline();
KeyValue kv = new KeyValue(root.translateYProperty(), 0 , Interpolator.EASE_BOTH);
KeyFrame kf = new KeyFrame(Duration.seconds(.5), kv);
timeline.getKeyFrames().add(kf);
timeline.play();
parentContainer.getChildren().remove(parentContainer);
}
@FXML
public void Files(){}
@FXML
public void Settings(){}
@FXML
public void Close(){
Platform.exit();
}
}
Calc 类可在 @Tobias 答案中找到。当我运行项目时,我只需启动 Main 类
最佳答案
我猜想,UI 在计算期间挂起,因此不会显示您的指示器,因为 UI 无法更新。最后,当计算完成时,指示器将被设置为可见,然后再次不可见,因为计算完成了(这可能是指示器短暂闪烁的原因)。
解决方案是将计算放在一个新的Thread
中,这样它就可以并行运行,并且UI线程不会被计算阻塞。
看看this answer例如,了解如何创建新线程。
关于当我设置 Progress-Indicator.setVisible(true) 时,Javafx Progress-Indicator 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57089339/
我的Angular-Component位于一个flexbox(id =“log”)中。可以显示或隐藏flexbox。 我的组件内部有一个可滚动区域,用于显示日志消息。 (id =“message-li
我真的很困惑 有一个 phpinfo() 输出: MySQL 支持 启用 客户端 API 版本 5.5.40 MYSQL_MODULE_TYPE 外部 phpMyAdmin 显示: 服务器类型:Mar
我正在研究这个 fiddle : http://jsfiddle.net/cED6c/7/我想让按钮文本在单击时发生变化,我尝试使用以下代码: 但是,它不起作用。我应该如何实现这个?任何帮助都会很棒
我应该在“dogs_cats”中保存表“dogs”和“cats”各自的ID,当看到数据时显示狗和猫的名字。 我有这三个表: CREATE TABLE IF NOT EXISTS cats ( id
我有一个字符串返回到我的 View 之一,如下所示: $text = 'Lorem ipsum dolor ' 我正在尝试用 Blade 显示它: {{$text}} 但是,输出是原始字符串而不是渲染
我无法让我的链接(由图像表示,位于页面左侧)真正有效地显示一个 div(包含一个句子,位于中间)/单击链接时隐藏。 这是我的代码: Practice
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
最初我使用 Listview 来显示 oracle 结果,但是最近我不得不切换到 datagridview 来处理比 Listview 允许的更多的结果。然而,自从切换到数据网格后,我得到的结果越来越
我一直在尝试插入一个 Unicode 字符 ∇ 或 ▽,所以它显示在 Apache FOP 生成的 PDF 中。 这是我到目前为止所做的: 根据这个基本帮助 Apache XSL-FO Input,您
我正在使用 node v0.12.7 编写一个 nodeJS 应用程序。 我正在使用 pm2 v0.14.7 运行我的 nodejs 应用程序。 我的应用程序似乎有内存泄漏,因为它从我启动时的大约 1
好的,所以我有一些 jQuery 代码,如果从下拉菜单中选择了带有前缀 Blue 的项目,它会显示一个输入框。 代码: $(function() { $('#text1').hide();
当我试图检查 Chrome 中的 html 元素时,它显示的是 LESS 文件,而 Firefox 显示的是 CSS 文件。 (我正在使用 Bootstrap 框架) 如何在 Chrome 中查看 c
我是 Microsoft Bot Framework 的新手,我正在通过 youtube 视频 https://youtu.be/ynG6Muox81o 学习它并在 Ubuntu 上使用 python
我正在尝试转换从 mssql 生成的文件到 utf-8。当我打开他的输出 mssql在 Windows Server 2003 中使用 notepad++ 将文件识别为 UCS-2LE我使用 file
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我正在尝试执行单击以打开/关闭一个 div 的功能。 这是基本的,但是,点击只显示 div,当我点击“关闭”时,没有任何反应。 $(".inscricao-email").click(function
假设我有 2 张卡片,屏幕上一次显示一张。我有一个按钮可以用其他卡片替换当前卡片。现在假设卡 1 上有一些数据,卡 2 上有一些数据,我不想破坏它们每个上的数据,或者我不想再次重建它们中的任何一个。
我正在使用 Eloquent Javascript 学习 Javascript。 我在 Firefox 控制台上编写了以下代码,但它返回:“ReferenceError:show() 未定义”为什么?
我正在使用 Symfony2 开发一个 web 项目,我使用 Sonata Admin 作为管理面板,一切正常,但我想要做的是,在 Sonata Admin 的仪表板菜单上,我需要显示隐藏一些菜单取决
我试图显示一个div,具体取决于从下拉列表中选择的内容。例如,如果用户从列表中选择“现金”显示现金div或用户从列表中选择“检查”显示现金div 我整理了样本,但样本不完整,需要接线 http://j
我是一名优秀的程序员,十分优秀!