2016-03-01 139 views
0

我想用css規則調整JavaFx中HTMLEditor的行高,但找不到規則的名稱。 我試過-fx-line-height和其他一些但他們都沒有工作。這甚至是可能的,還是HTMLEditor太受限制了?行間距HTMLEditor JavaFx

回答

3

HTML編輯器編輯HTML,您需要指定line-height in HTML based CSS(不是JavaFX CSS)。

import javafx.application.Application; 
import javafx.scene.Scene; 
import javafx.scene.layout.Pane; 
import javafx.scene.web.HTMLEditor; 
import javafx.stage.Stage; 

public class SpacedOut extends Application { 

    private static final String HTML_TEXT = 
      "<p style=\"line-height:1.5\">\n" + 
      " <span style=\"font-size:12pt\">The quick brown fox jumps over the lazy dog.</span><br />\n" + 
      " <span style=\"font-size:24pt\">The quick brown fox jumps over the lazy dog.</span>\n" + 
      "</p>"; 

    @Override 
    public void start(Stage stage) throws Exception{ 
     HTMLEditor editor = new HTMLEditor(); 
     editor.setHtmlText(HTML_TEXT); 

     Scene scene = new Scene(new Pane(editor)); 
     stage.setScene(scene); 
     stage.show(); 
    } 

    public static void main(String[] args) { 
     launch(args); 
    } 
}