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.scrollbar;
  26 
  27 import javafx.event.ActionEvent;
  28 import javafx.event.EventHandler;
  29 import javafx.scene.Scene;
  30 import javafx.scene.control.*;
  31 import javafx.scene.control.test.utils.CommonPropertiesScene;
  32 import javafx.scene.control.test.utils.ptables.PropertiesTable;
  33 import javafx.scene.control.test.utils.ptables.PropertyTablesFactory;
  34 import javafx.scene.control.test.utils.ptables.SpecialTablePropertiesProvider;
  35 import javafx.scene.layout.HBox;
  36 import test.javaclient.shared.InteroperabilityApp;
  37 import test.javaclient.shared.Utils;
  38 
  39 /**
  40  * @author Alexander Kirov
  41  */
  42 public class ScrollBarApp extends InteroperabilityApp {
  43 
  44     public final static String TESTED_SCROLLBAR_ID = "TESTED_SCROLLBAR_ID";
  45     public final static String RESET_BUTTON_ID = "RESET_SLIDER_BUTTON_ID";
  46 
  47     public static void main(String[] args) {
  48         Utils.launch(ScrollBarApp.class, args);
  49     }
  50 
  51     @Override
  52     protected Scene getScene() {
  53         Utils.setTitleToStage(stage, "ScrollBarTestApp");
  54         return new ScrollBarScene();
  55     }
  56 
  57     class ScrollBarScene extends CommonPropertiesScene {
  58 
  59         PropertiesTable tb;
  60         ScrollBar testedScrollBar;
  61 
  62         public ScrollBarScene() {
  63             super("ScrollBar", 800, 600);
  64             prepareScene();
  65         }
  66 
  67         @Override
  68         final protected void prepareScene() {
  69             testedScrollBar = new ScrollBar();
  70             testedScrollBar.setFocusTraversable(true);
  71             testedScrollBar.setId(TESTED_SCROLLBAR_ID);
  72 
  73             tb = new PropertiesTable(testedScrollBar);
  74             PropertyTablesFactory.explorePropertiesList(testedScrollBar, tb);
  75             SpecialTablePropertiesProvider.provideForControl(testedScrollBar, tb);
  76 
  77             Button resetButton = new Button("Reset");
  78             resetButton.setId(RESET_BUTTON_ID);
  79             resetButton.setOnAction(new EventHandler<ActionEvent>() {
  80                 public void handle(ActionEvent t) {
  81                     HBox hb = (HBox) getRoot();
  82                     hb.getChildren().clear();
  83                     prepareMainSceneStructure();
  84                     prepareScene();
  85                 }
  86             });
  87 
  88             setControllersContent(resetButton);
  89             setTestedControl(testedScrollBar);
  90             setPropertiesContent(tb);
  91         }
  92     }
  93 }