zoukankan      html  css  js  c++  java
  • javafx style and cssFile

    public class EffectTest extends Application {
    
     public static void main(String[] args) {
        launch(args);
      }
    
      @Override
      public void start(Stage stage) {
        stage.setTitle("ComboBoxSample");
        Scene scene = new Scene(new Group(), 450, 250);
    
        TextField notification = new TextField();
    
        final ContextMenu contextMenu = new ContextMenu();
        contextMenu.setOnShowing((WindowEvent e) -> {
            System.out.println("showing");
        });
        contextMenu.setOnShown((WindowEvent e) -> {
            System.out.println("shown");
        });
    
        MenuItem item1 = new MenuItem("About");
        item1.setOnAction((ActionEvent e) -> {
            System.out.println("About");
        });
        MenuItem item2 = new MenuItem("Preferences");
        item2.setOnAction((ActionEvent e) -> {
            System.out.println("Preferences");
        });
        contextMenu.getItems().addAll(item1, item2);
    
        notification.setContextMenu(contextMenu);
      
        
        
        
        GridPane grid = new GridPane();
        grid.setVgap(4);
        grid.setHgap(10);
        grid.setPadding(new Insets(5, 5, 5, 5));
        grid.add(new Label("To: "), 0, 0);
        grid.add(notification, 2, 3);
        Text text = new Text();
            text.setId("fancytext");
            text.setStyle("#fancytext {-fx-fill: white;-fx-font: 120px Harlow; }");
            text.setX(20);
            text.setY(150);
            
            grid.add(text, 3, 2);
        
        final String cssDefault = "-fx-border-color: blue;
    "
                +"-fx-background-color: black;"
                    + "-fx-border-insets: 5;
    "
                    + "-fx-border- 3;
    "
                    + "-fx-border-style: dashed;
    ";
    //grid.setStyle("-fx-background-color: black;");
        
        
      
        
        
        grid.setStyle(cssDefault);
        Group root = (Group) scene.getRoot();
     
        
        root.getChildren().add(grid);
        
        
        
        
        
            scene.setFill(null);
            
            String cssFile1 = this.getClass().getResource("x.css").toExternalForm();
            String cssFile2 = this.getClass().getResource("Styles.css").toExternalForm();
            String cssFile3 = this.getClass().getResource("/cssStyles/base.css").toExternalForm();
            scene.getStylesheets().addAll(cssFile1, cssFile2, cssFile3);
        stage.setScene(scene);
        stage.show();
    
      }
      
    }
  • 相关阅读:
    jenkins部署前端node项目实例
    阿里云云盘扩容数据盘_Linux
    输入子系统
    触摸屏设备驱动程序
    LCD设备驱动程序
    IIC设备驱动程序
    看门狗驱动程序
    RTC实时时钟驱动
    网络设备驱动程序数据结构
    Linux 设备驱动模型
  • 原文地址:https://www.cnblogs.com/rojas/p/4720957.html
Copyright © 2011-2022 走看看