如何在JavaFX中增加进度条的大小

时间:2017-05-24 09:01:43

标签: javafx alignment

  1. 我在Javafx中设计UI有一些进度条组件的问题。      我希望进度条的大小适合下面示例中的窗口大小。任何一个帮助都可以对齐它。
  2. Click her for UI

    import java.util.Random;

        import javafx.application.Application;
        import javafx.scene.Group;
        import javafx.scene.Scene;
        import javafx.scene.control.*;
        import javafx.scene.image.Image;
        import javafx.scene.layout.GridPane;
        import javafx.scene.text.Font;
        import javafx.stage.Stage;
    
        public class SampleCode extends Application {
    
            Label l1 = new Label("Loading channel(s) details from NE... ");
            Label l2 = new Label("Please wait...");
            public final static String cssFilePath = "MainPage.css";
    
            @Override
            public void start(Stage stage) {
                Group root = new Group();
                Scene scene = new Scene(root, 350, 50);
                stage.setScene(scene);
                stage.setTitle("1830 PSS-APA");
                scene.getStylesheets().add(getClass().getResource(cssFilePath).toExternalForm());
                GridPane grid = new GridPane();
    
                scene.setRoot(grid);
    
                Image nokiaIconImg = new Image(SampleCode.class.getResource("nokiaicon.jpg").toExternalForm());
    
                grid.getChildren().add(l1);
                GridPane.setConstraints(l2, 0, 2);
                GridPane.setColumnSpan(l2, 3);
                grid.getChildren().add(l2);
    
                ProgressBar p2 = new ProgressBar();
    
                grid.getChildren().add(p2);
                GridPane.setConstraints(p2, 0, 4);
                GridPane.setColumnSpan(p2, 4);
    
                stage.getIcons().add(nokiaIconImg);
    
                stage.show();
    
            }
    
            public static void main(String[] args) {
                launch(args);
            }
        }
    

0 个答案:

没有答案