/* * To change this template, choose Tools | Templates and open the template in * the editor. */ import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Orientation; import javafx.geometry.Pos; import javafx.scene.Cursor; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.effect.BlendMode; import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.BorderPane; import javafx.scene.paint.Color; import javafx.stage.Popup; import javafx.stage.Stage; public class JavaFXApplication extends Application { public static void main(String[] args) { Application.launch(JavaFXApplication.class, args); } public int count; @Override public void start(Stage stage) { final Stage primaryStage = stage; primaryStage.setTitle("Тестирование GUI-компонентов"); TextField textField = new TextField(); textField.setCursor(Cursor.TEXT); textField.setPrefSize(200, 20); Button btnS = new Button("Search"); btnS.setStyle("-fx-font:bold 12pt Arial"); btnS.setOnAction(new EventHandler() { @Override public void handle(ActionEvent t) { System.out.println("OnAction() Search " + ++count); } }); btnS.setOnMouseClicked(new EventHandler() { public void handle(MouseEvent event) { System.out.println("OnMouseClicked() Search " + ++count); } }); Separator sep = new Separator(); sep.setOrientation(Orientation.VERTICAL); sep.setPrefHeight(20); Button btnA = new Button("Extended Search"); btnA.setStyle("-fx-font:bold 12pt Arial"); btnA.setOnAction(new EventHandler() { @Override public void handle(ActionEvent t) { System.out.println("OnAction() Extended Search " + ++count); } }); btnA.setOnMouseClicked(new EventHandler() { public void handle(MouseEvent event) { System.out.println("OnMouseClicked() Extended Search " + ++count ); } }); ToolBar toolBar = new ToolBar(); toolBar.setLayoutX(20); toolBar.setLayoutY(20); toolBar.setBlendMode(BlendMode.HARD_LIGHT); toolBar.setCursor(Cursor.HAND); toolBar.setOrientation(Orientation.HORIZONTAL); toolBar.getItems().addAll(textField, btnS, sep, btnA); BorderPane root = new BorderPane(); Scene scene = new Scene(root, 600, 500, Color.LIGHTGREEN); primaryStage.setScene(scene); primaryStage.show(); root.setTop(toolBar); } }