2012-04-08 57 views
0

我無法弄清楚如何將這種效果應用到javaFX 2中的文本字段使用CSS(-fx -...:...);JavaFX CSS效果幫助(屏幕截圖)

enter image description here

我需要類似的截圖。我有一個具有該背景的面板,我需要文本字段將它變暗一點(它看起來像是一個內部陰影)。

我嘗試在面板上使用較小的不透明度,並在文本輸入上使用高不透明度,但工作不正常。

謝謝。

回答

1

運行此示例應用程序:

import javafx.application.Application; 
import javafx.scene.Scene; 
import javafx.scene.control.TextField; 
import javafx.scene.layout.Pane; 
import javafx.stage.Stage; 

public class StyleDemo extends Application { 

    @Override 
    public void start(Stage primaryStage) { 
     TextField txt = new TextField("text"); 
     txt.setLayoutY(150); 
     txt.setPrefHeight(50); 
     txt.setStyle("-fx-background-color: rgb(0,0,0,0.11); -fx-text-fill: white; -fx-font-size: 28; -fx-font-weight: bold"); 

     Pane root = new Pane(); 
     root.setStyle("-fx-background-image: url(\"http://i.stack.imgur.com/ThghN.png\"); -fx-background-repeat: stretch; -fx-background-size: 300 250;"); 
     root.getChildren().add(txt); 
     primaryStage.setScene(new Scene(root, 300, 250)); 
     primaryStage.show(); 
    } 

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

舉個內陰影效果文本字段,檢查此鏈接了:
http://docs.oracle.com/javafx/2.0/api/javafx/scene/doc-files/cssref.html#typeeffect