Tables in JTextPane and cell spanning (cell merging)
I have a question. I need to know, if it is possible to insert table in JEditorPane
(I have found an example at http://java-sl.com/JEditorPaneTables.html) without using HTML and to use the column and row spanning cells.开发者_如何学Python In short I need to insert a table like this:
+-------+--------+-------+ | first | second | third | +-------+--------+-------+ | c1 | col. spanning | +-------+--------+-------+ | c2 | | c3 | +-------+ row s. +-------+ | c4 | | c5 | +-------+--------+-------+
I tried to google it, but I nowhere have found, what I am looking for. The question of the spanning cells is perhaps not so common.
JUst Use HTMLEditorKit and insert desired tabel with row and col spans. You can use the method
public void insertHTML(HTMLDocument doc, int offset, String html,
int popDepth, int pushDepth,
HTML.Tag insertTag)
or you can get HTMLDocument and use one of the
public void insertAfterStart(Element elem, String htmlText)
public void insertBeforeEnd(Element elem, String htmlText)
public void insertBeforeStart(Element elem, String htmlText)
public void insertAfterEnd(Element elem, String htmlText)
public void setOuterHTML(Element elem, String htmlText)
public void setInnerHTML(Element elem, String htmlText)
精彩评论