package javafx_lighting; import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.effect.Lighting; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.HBox; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Rectangle; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; /** * @web http://java-buddy.blogspot.com/ */ public class JavaFX_Lighting extends Application { @Override public void start(Stage primaryStage) { Button btn1 = new Button(); btn1.setText("Normal Button"); Button btn2 = new Button(); btn2.setText("Button with Lighting"); btn2.setEffect(new Lighting()); TextField textField1 = new TextField("Normal TextField"); TextField textField2 = new TextField("TextField with Lighting"); textField2.setEffect(new Lighting()); Text text1 = new Text("Normal Text"); text1.setFont(Font.font ("Verdana", FontWeight.BOLD, 40)); text1.setFill(Color.RED); Text text2 = new Text("Text with lighting"); text2.setFont(Font.font ("Verdana", FontWeight.BOLD, 40)); text2.setFill(Color.RED); text2.setEffect(new Lighting()); Circle circle1 = new Circle(20, Color.rgb(156,216,255)); Circle circle2 = new Circle(20, Color.rgb(156,216,255)); circle2.setEffect(new Lighting()); Rectangle rectangle1 = new Rectangle(100, 100, Color.rgb(156,216,255)); Rectangle rectangle2 = new Rectangle(100, 100, Color.rgb(156,216,255)); rectangle2.setEffect(new Lighting()); HBox hBoxShape = new HBox(); hBoxShape.getChildren().addAll(rectangle1, rectangle2, circle1, circle2); ImageView imageView1 = new ImageView(new Image("http://goo.gl/kYEQl")); ImageView imageView2 = new ImageView(new Image("http://goo.gl/kYEQl")); imageView2.setEffect(new Lighting()); HBox hBoxImageView = new HBox(); hBoxImageView.getChildren().addAll(imageView1, imageView2); VBox vBox = new VBox(); vBox.setPadding(new Insets(10, 10, 10, 10)); vBox.getChildren().addAll(btn1, btn2, text1, text2, textField1, textField2, hBoxShape, hBoxImageView); StackPane root = new StackPane(); root.getChildren().add(vBox); Scene scene = new Scene(root, 450, 400); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
Tuesday, September 22, 2015
JavaFX Lighting effect
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment