2017-03-10 5 views
1

ProgressIndicatorの下にある割合のテキストを削除しようとしましたが、失敗しました。私は割合フォントを変更することができていますので、私は、ロードされているこのの言及いくつか発見され、受け入れられた答えをしようとしたが、それは、Java 8にアップデート121JavaFX:ProgressIndicatorの割合を削除します

私はCSSを知って
package com.company.mytest; 

import javafx.application.Application; 
import javafx.scene.Scene; 
import javafx.scene.control.Label; 
import javafx.scene.control.ProgressIndicator; 
import javafx.scene.layout.StackPane; 
import javafx.stage.Stage; 

public class ProgressApp extends Application { 

    public static void main(String[] args) { 
     launch(args); 
    } 

    /* (non-Javadoc) 
    * @see javafx.application.Application#start(javafx.stage.Stage) 
    */ 
    @Override 
    public void start(Stage stage) throws Exception { 
     ProgressIndicator progress = new ProgressIndicator(); 
     progress.setProgress(0.5f); 

     StackPane root = new StackPane(); 
     root.getChildren().add(progress); 

     Scene scene = new Scene(root); 

     scene.getStylesheets() 
     .add(getClass().getResource("progress.css").toExternalForm()); 

     stage.setScene(scene); 
     stage.setWidth(300); 
     stage.setHeight(300); 
     stage.setTitle("JavaFX 8 app"); 
     stage.show(); 
    } 

} 

を使用して

動作しないいますサイズ。これはprogress.cssファイルのCSSコンテンツです。 null-fx-fill属性を設定

.progress-indicator .percentage { 
    visibility: hidden; 
} 

答えて

1

は、問題を解決するようだ:

.progress-indicator .percentage { 
    -fx-fill:null; 
} 

更新:

のみ、この属性がパーセンテージテキストを隠し、まだ占め設定しますスペース。これはまた、持っている.progress-indicator .percentageためのCSSが変更された場合(例えば、より大きなフォントサイズ):

.progress-indicator .percentage { 
    -fx-fill:null; 
} 

.progress-indicator { 
    -fx-padding: 0 0 -16 0; 
} 

唯一の問題は、ハードコードされた値は次のとおりです。

可能な回避策はProgressIndicator-fx-padding属性を設定することです適合させる。


また

この答えではプログラムによるソリューション:How can I avoid the display of percentage values, when using the ProgressIndicator of JavaFX UI Controls

+0

はい、それはまだスペースを占有。フォントサイズを非常に小さく設定しても、パーセンテージは使用するスペースよりも多くのスペースを占有します。 – DJViking

+0

はい、そうです。更新された回答を確認してください。 – DVarga

+0

パディングを設定することはやりました。しかし、ボトムパッディングのためにハードコードされた負の値を設定することは理想的ではありませパフォーマンスに付加的なオーバーヘッドがない場合は、プログラマチックソリューションを使用するほうがよいでしょう。 – DJViking

関連する問題