/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package fxmlsandbox; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; /** * * @author Milan */ public class StyledTextField extends Application { @Override public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Say 'Hello World'"); btn.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { System.out.println("Hello World!"); } }); AnchorPane root = new AnchorPane(); AnchorPane.setTopAnchor(btn, 10.0); AnchorPane.setLeftAnchor(btn, 10.0); root.getChildren().add(btn); TextField field = new TextField(); field.setPromptText("Prompt:"); // field.setStyle("" // -fx-prompt-text-fill: darkblue; // + " -fx-background-color: #999999, white;\n" // + " -fx-background-insets: 1, 3;\n" // + " -fx-background-radius: 0 0 9 0, 0 0 8 0, 0 0 8 0;\n" // + " -fx-padding: 5px}"); AnchorPane.setTopAnchor(field, 50.0); AnchorPane.setLeftAnchor(field, 10.0); root.getChildren().add(field); Scene scene = new Scene(root, 500, 500); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); } /** * The main() method is ignored in correctly deployed JavaFX application. * main() serves only as fallback in case the application can not be * launched through deployment artifacts, e.g., in IDEs with limited FX * support. NetBeans ignores main(). * * @param args the command line arguments */ public static void main(String[] args) { launch(args); } }