Reputation: 5778
I have an FXML file that has a Pane as one of it's entries, used for the output of our program. I would like to have this Pane contain an HTMLEditor. I'm a little bit confused at what to do to accomplish this. The class uses the Singleton pattern as recommended, and I can call into the Controller to get the Pane.
Then I find myself having to create an inner class, since HTMLEditor is not a Node. So I extended rectangle to do this, and use getChildren.add(htmlEditorWrapper) to try and add it as a Node. Of course, the HTMLEditor does not show up when I run the program.
The gist of my question: How do I add an HTMLEditor to a Pane (which is in the fxml file)?
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);
}
}
Upvotes: 0
Views: 5977
Reputation: 999
Actually HtmlEditor is a Node
. Try adding it directly.
And how did you obtain an editor by extending Rectangle
?
Upvotes: 3