1 /*
   2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation. Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package javafx.scene.control.test.Tooltip;
  26 
  27 import javafx.event.ActionEvent;
  28 import javafx.event.EventHandler;
  29 import javafx.geometry.Insets;
  30 import javafx.scene.Scene;
  31 import javafx.scene.control.*;
  32 import javafx.scene.control.test.utils.CommonPropertiesScene;
  33 import javafx.scene.control.test.utils.ptables.PropertiesTable;
  34 import javafx.scene.control.test.utils.ptables.PropertyTablesFactory;
  35 import javafx.scene.layout.HBox;
  36 import javafx.scene.layout.Pane;
  37 import javafx.scene.layout.VBox;
  38 import test.javaclient.shared.InteroperabilityApp;
  39 import test.javaclient.shared.Utils;
  40 
  41 /**
  42  * @author Alexander Kirov
  43  */
  44 public class NewTooltipApp extends InteroperabilityApp {
  45 
  46     public final static String TESTED_TOOLTIP_ID = "TESTED_TOOLTIP_ID";
  47     public final static String RESET_BUTTON_ID = "RESET_Tooltip_BUTTON_ID";
  48 
  49     public static void main(String[] args) {
  50         Utils.launch(NewTooltipApp.class, args);
  51     }
  52 
  53     @Override
  54     protected Scene getScene() {
  55         Utils.setTitleToStage(stage, "TooltipTestApp");
  56         return new NewTooltipApp.TooltipScene();
  57     }
  58 
  59     class TooltipScene extends CommonPropertiesScene {
  60 
  61         //VBox which contain tested tooltip.
  62         Pane pane;
  63         PropertiesTable tb;
  64         //Tooltip to be tested.
  65         Tooltip testedTooltip;
  66 
  67         public TooltipScene() {
  68             super("Tooltip", 800, 600);
  69 
  70             prepareScene();
  71         }
  72 
  73         @Override
  74         final protected void prepareScene() {
  75             pane = new Pane();
  76             testedTooltip = new Tooltip();
  77             testedTooltip.setId(TESTED_TOOLTIP_ID);
  78 
  79             tb = new PropertiesTable(testedTooltip);
  80             PropertyTablesFactory.explorePropertiesList(testedTooltip, tb);
  81 
  82             Button button = new Button("Tooltip attached.");
  83             button.setTooltip(testedTooltip);
  84 
  85             pane.setMinSize(220, 220);
  86             pane.setPrefSize(220, 220);
  87             pane.setStyle("-fx-border-color : red;");
  88             pane.getChildren().add(button);
  89 
  90             VBox vb = new VBox();
  91             vb.setSpacing(5);
  92 
  93             HBox hb = (HBox) getRoot();
  94             hb.setPadding(new Insets(5, 5, 5, 5));
  95             hb.setStyle("-fx-border-color : green;");
  96 
  97             Button resetButton = new Button("Reset");
  98             resetButton.setId(RESET_BUTTON_ID);
  99             resetButton.setOnAction(new EventHandler<ActionEvent>() {
 100                 public void handle(ActionEvent t) {
 101                     HBox hb = (HBox) getRoot();
 102                     hb.getChildren().clear();
 103                     prepareScene();
 104                 }
 105             });
 106 
 107             setControllersContent(resetButton);
 108             setPropertiesContent(tb);
 109         }
 110     }
 111 }