Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Java/JavaFX中的HTMLEditor中输入新行_Java_Javafx_Newline_Html Editor - Fatal编程技术网

在Java/JavaFX中的HTMLEditor中输入新行

在Java/JavaFX中的HTMLEditor中输入新行,java,javafx,newline,html-editor,Java,Javafx,Newline,Html Editor,我对JPanel中使用的HTMLEditor有问题。一切正常,但按ENTER键转到新行不起作用 我的代码: public class MessageEditor extends JPanel { private HTMLEditor htmlEditor; private Scene scene; private JFXPanel jfxPanel; public MessageEditor() { jfxPanel = new JFXPan

我对JPanel中使用的HTMLEditor有问题。一切正常,但按ENTER键转到新行不起作用

我的代码:

public class MessageEditor extends JPanel {

    private HTMLEditor htmlEditor;
    private Scene scene;
    private JFXPanel jfxPanel;

    public MessageEditor() {

        jfxPanel = new JFXPanel();

        this.setLayout(new BorderLayout());

        loadJavaFXScene();
    }

    private void loadJavaFXScene() {

        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                htmlEditor = new HTMLEditor();
                scene = new Scene(htmlEditor, 450, 450);
                scene.setRoot(htmlEditor);
                htmlEditor.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
                    @Override
                    public void handle(KeyEvent event) {
                        logger.debug("KE: " + event);


                jfxPanel.setScene(scene);

                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        add(jfxPanel, BorderLayout.CENTER);
                        revalidate();
                        repaint();
                    }
                });
            }
        });
    }
可能重复的
KeyEvent [source = HTMLEditor[id=null, styleClass=root], target = WebView@e9bb131[styleClass=web-view], eventType = KEY_PRESSED, consumed = false, character = , code = ENTER]