changeset 5931:2883ec7be017

Ensemble8: Fix for RT-34448 HTML Editor in Ensemble8 is not completely visible
author Alexander Kouznetsov
date Mon, 09 Dec 2013 13:36:17 -0800
parents a5d957304de7
children 98ffb00297f5
files apps/samples/Ensemble8/src/samples/java/ensemble/samples/web/htmleditor/HTMLEditorApp.java
diffstat 1 files changed, 21 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/apps/samples/Ensemble8/src/samples/java/ensemble/samples/web/htmleditor/HTMLEditorApp.java	Mon Dec 09 13:18:07 2013 -0800
+++ b/apps/samples/Ensemble8/src/samples/java/ensemble/samples/web/htmleditor/HTMLEditorApp.java	Mon Dec 09 13:36:17 2013 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013 Oracle and/or its affiliates.
+ * Copyright (c) 2008, 2013, Oracle and/or its affiliates.
  * All rights reserved. Use is subject to license terms.
  *
  * This file is available and licensed under the following license:
@@ -34,7 +34,6 @@
 import javafx.application.Application;
 import javafx.event.ActionEvent;
 import javafx.event.EventHandler;
-import javafx.geometry.Insets;
 import javafx.geometry.Pos;
 import javafx.scene.Parent;
 import javafx.scene.Scene;
@@ -53,34 +52,38 @@
  * @sampleName HTML Editor
  * @preview preview.png
  * @see javafx.scene.web.HTMLEditor
+ * @see javafx.scene.control.ScrollPane
+ * @see javafx.scene.control.ScrollPane.ScrollBarPolicy
+ * @see javafx.scene.control.Button
+ * @see javafx.event.ActionEvent
+ * @see javafx.event.EventHandler
+ * @see javafx.geometry.Pos
+ * @see javafx.scene.control.Label
+ * @see javafx.scene.layout.VBox
  * @related controls/text/SimpleLabel
  * @conditionalFeatures WEB
  */
 public class HTMLEditorApp extends Application {
 
-   private HTMLEditor htmlEditor = null;
-    private final String INITIAL_TEXT = "<html><body>Lorem ipsum dolor sit amet, consectetur adipiscing elit."
-            +"Nam tortor felis, pulvinar in scelerisque cursus, pulvinar at ante. Nulla consequat "
+    private HTMLEditor htmlEditor = null;
+    private final String INITIAL_TEXT = "<html><body>Lorem ipsum dolor sit "
+            + "amet, consectetur adipiscing elit."
+            + "Nam tortor felis, pulvinar in scelerisque cursus, pulvinar "
+            + "at ante. Nulla consequat "
             + "congue lectus in sodales. </body></html> ";
 
     public Parent createContent() {
 
-        VBox vRoot = new VBox();
-        vRoot.setPrefWidth(300);
-        vRoot.setSpacing(5);
-
         htmlEditor = new HTMLEditor();
-        htmlEditor.setPrefHeight(245);
         htmlEditor.setHtmlText(INITIAL_TEXT);
 
         ScrollPane htmlSP = new ScrollPane();
         htmlSP.setFitToWidth(true);
+        htmlSP.setPrefWidth(htmlEditor.prefWidth(-1)); // Workaround of RT-21495
         htmlSP.setPrefHeight(245);
         htmlSP.setVbarPolicy(ScrollBarPolicy.NEVER);
         htmlSP.setContent(htmlEditor);
-                      
-        vRoot.getChildren().add(htmlSP);        
-        
+
         final Label htmlLabel = new Label();
         htmlLabel.setWrapText(true);
 
@@ -90,7 +93,6 @@
         scrollPane.setFitToWidth(true);
 
         Button showHTMLButton = new Button("Show the HTML below");
-        vRoot.setAlignment(Pos.CENTER);
         showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {
 
             @Override
@@ -99,8 +101,11 @@
             }
         });
 
-        vRoot.getChildren().addAll(showHTMLButton, scrollPane);
-      
+        VBox vRoot = new VBox();
+        vRoot.setAlignment(Pos.CENTER);
+        vRoot.setSpacing(5);
+        vRoot.getChildren().addAll(htmlSP, showHTMLButton, scrollPane);
+
         return vRoot;
     }