HTML Editor with Java and And webkit - SWT Browser

你离开我真会死。 提交于 2019-12-04 05:12:31

The DJ Native Swing project has several HTML editors, implemented using the SWT Browser (this is an implementation detail): http://djproject.sourceforge.net/ns

I like it that you asked some very specific questions! Good job brainstorming before you get your hands dirty.

Fortunately, there's a fairly generic solution to your problem: just run JavaScript in the browser.

For instance:

Browser browser = new Browser(parent, SWT.NONE);
// Just to be sure we can use JavaScript
browser.setJavascriptEnabled(true);
boolean result = browser.execute("alert('Hello SWT!')");
if (result) {
    System.out.println("script executed");
} else {
    System.err.println("script failed to execute");
}

Of course you might want to send data from the browser back to SWT; in this case you might end up in the worst case having to parse browser.getText(). I'm not sure if there's a better way of doing this.

Thy this one tinymc: http://tinymce.moxiecode.com/ It's well documented and you can integrate it into almost any existing code as it has a nice interface and lots of plugins.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!