プログラムの出力に使用されるエントリの 1 つとして Pane を持つ FXML ファイルがあります。このペインに HTMLEditor を含めたいと思います。これを達成するために何をすべきかについて少し混乱しています。このクラスは、推奨されるシングルトン パターンを使用し、コントローラーを呼び出してペインを取得できます。
HTMLEditor はノードではないため、内部クラスを作成する必要があります。そこで、これを行うために長方形を拡張し、getChildren.add(htmlEditorWrapper) を使用してノードとして追加しようとしました。もちろん、プログラムを実行しても HTMLEditor は表示されません。
私の質問の要点:HTMLEditorをペイン(fxmlファイルにある)に追加するにはどうすればよいですか?
import javafx.scene.layout.Pane;
import javafx.scene.shape.Rectangle;
import javafx.scene.web.HTMLEditor;
/**
* Gets the controller's outputPane (the console in the gui)
* @author Matt
*
*/
public class OutputPanel{
private static Pane pane;
private static HtmlEditorWrap htmlEditor = new HtmlEditorWrap();
private static final OutputPanel outputPanel = new OutputPanel();
private OutputPanel(){}
public static OutputPanel getInstance(){
pane = Controller.getOutputPane();
pane.getChildren().add(htmlEditor);
return outputPanel;
}
public void clear(){
//htmlEditor.setHtmlText();
}
public static void write(String text){
htmlEditor.setHtmlText(text + "\n");
}
}
class HtmlEditorWrap extends Rectangle{
HTMLEditor htmlEditor = new HTMLEditor();
public HtmlEditorWrap(){
htmlEditor.setLayoutX(200);
htmlEditor.setLayoutY(200);
htmlEditor.setHtmlText("TESTING");
}
public void setHtmlText(String text){
htmlEditor.setHtmlText(text);
}
}