apps/toys/Hello/src/main/java/hello/HelloTitledPane.java

Print this page
rev 7157 : RT-37173: change selector to match scene-graph of a TitledPane


  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 
  26 package hello;
  27 
  28 import javafx.application.Application;
  29 import javafx.geometry.Insets;
  30 import javafx.scene.Group;
  31 import javafx.scene.Scene;
  32 import javafx.scene.control.Button;
  33 import javafx.scene.control.Label;

  34 import javafx.scene.control.TextField;
  35 import javafx.scene.control.TitledPane;


  36 import javafx.scene.layout.GridPane;
  37 import javafx.scene.layout.HBox;
  38 import javafx.scene.layout.StackPane;
  39 import javafx.scene.layout.VBox;
  40 import javafx.scene.paint.Color;
  41 import javafx.scene.text.Font;
  42 import javafx.stage.Stage;
  43 
  44 public class HelloTitledPane extends Application {
  45     
  46     public static void main(String[] args) {
  47         Application.launch(args);
  48     }
  49 
  50     @Override public void start(Stage stage) {
  51         stage.setTitle("TitledPane");
  52 
  53         // --- Simple grid test
  54         TitledPane gridTitlePane = new TitledPane();
  55         GridPane grid = new GridPane();


  78         StackPane pane = new StackPane(bn);
  79         pane.setPadding(new Insets(5));
  80         normal.setText("Hello World!");
  81         normal.setFont(Font.font(5));
  82         normal.setContent(pane);
  83 
  84         TitledPane unanimated = new TitledPane();
  85         unanimated.setAnimated(false);
  86         unanimated.setText("Not Animated");
  87         Button bs = new Button("Button");
  88         bs.setPrefSize(75, 50);
  89         unanimated.setContent(bs);
  90 
  91         TitledPane uncollapsible = new TitledPane();
  92         uncollapsible.setCollapsible(false);
  93         uncollapsible.setText("Not Collapsible");
  94         Button bf = new Button("Button");
  95         bf.setPrefSize(75, 50);
  96         uncollapsible.setContent(bf);
  97 













  98         VBox hbox = new VBox(10);
  99         hbox.setPadding(new Insets(20, 0, 0, 20));
 100         hbox.getChildren().setAll(normal, gridTitlePane, normalText, unanimated, uncollapsible);
 101 
 102         Scene scene = new Scene(hbox);
 103         scene.setFill(Color.GHOSTWHITE);
 104         stage.setScene(scene);
 105         stage.show();
 106     }
 107 }


  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 
  26 package hello;
  27 
  28 import javafx.application.Application;
  29 import javafx.geometry.Insets;
  30 import javafx.scene.Group;
  31 import javafx.scene.Scene;
  32 import javafx.scene.control.Button;
  33 import javafx.scene.control.Label;
  34 import javafx.scene.control.ScrollPane;
  35 import javafx.scene.control.TextField;
  36 import javafx.scene.control.TitledPane;
  37 import javafx.scene.image.Image;
  38 import javafx.scene.image.ImageView;
  39 import javafx.scene.layout.GridPane;
  40 import javafx.scene.layout.HBox;
  41 import javafx.scene.layout.StackPane;
  42 import javafx.scene.layout.VBox;
  43 import javafx.scene.paint.Color;
  44 import javafx.scene.text.Font;
  45 import javafx.stage.Stage;
  46 
  47 public class HelloTitledPane extends Application {
  48     
  49     public static void main(String[] args) {
  50         Application.launch(args);
  51     }
  52 
  53     @Override public void start(Stage stage) {
  54         stage.setTitle("TitledPane");
  55 
  56         // --- Simple grid test
  57         TitledPane gridTitlePane = new TitledPane();
  58         GridPane grid = new GridPane();


  81         StackPane pane = new StackPane(bn);
  82         pane.setPadding(new Insets(5));
  83         normal.setText("Hello World!");
  84         normal.setFont(Font.font(5));
  85         normal.setContent(pane);
  86 
  87         TitledPane unanimated = new TitledPane();
  88         unanimated.setAnimated(false);
  89         unanimated.setText("Not Animated");
  90         Button bs = new Button("Button");
  91         bs.setPrefSize(75, 50);
  92         unanimated.setContent(bs);
  93 
  94         TitledPane uncollapsible = new TitledPane();
  95         uncollapsible.setCollapsible(false);
  96         uncollapsible.setText("Not Collapsible");
  97         Button bf = new Button("Button");
  98         bf.setPrefSize(75, 50);
  99         uncollapsible.setContent(bf);
 100 
 101         // -- Content is a ScrollPane
 102         Image image = new Image("hello/duke.jpg", 200f, 200f, true, true, false);
 103         ImageView imageView = new ImageView();
 104         imageView.setImage(image);
 105 
 106         ScrollPane scrollPane = new ScrollPane(imageView);
 107         scrollPane.setPannable(true);
 108 
 109         TitledPane scrollableImage = new TitledPane();
 110         scrollableImage.setPrefHeight(100);
 111         scrollableImage.setText("ScrollPane content");
 112         scrollableImage.setContent(scrollPane);
 113 
 114         VBox hbox = new VBox(10);
 115         hbox.setPadding(new Insets(20, 0, 0, 20));
 116         hbox.getChildren().setAll(normal, gridTitlePane, normalText, unanimated, uncollapsible, scrollableImage);
 117 
 118         Scene scene = new Scene(hbox);
 119         scene.setFill(Color.GHOSTWHITE);
 120         stage.setScene(scene);
 121         stage.show();
 122     }
 123 }