Skip to content Skip to sidebar Skip to footer

Setting The Font And Style Of Jeditorpane

I am currently developing an application for this company as my last year of studies project, and in this application there's this function that allows you to print a paper, so i u

Solution 1:

See Adding custom shapes to JTextpane and saved to new Word document for references to two projects which use docx4j to provide rich text editing of docx within Swing.

Solution 2:

I found finally the solution after days of searching and testing, It turns out to be very simple actually.

All i had to do is use a metaphase editor panel, (which has a great toolbar by the way) create a DocxEditorkit and then set the editorkit of the metaphase editor panel's textpane to this DocxEditorKit, although the metamorphose works with HTML text pane, it miraculously worked...

DocxEditorKit DEK=new DocxEditorKit;
MetaphaseEditorPanel MEP=new MetaphaseEditorPanel;
MEP.getHTMLTextPane().setEditorKit(DEK);

   //Try and Catch blocks of course to read the file
DEK.read(new FileInputStream(PathToFile), MEP.getHTMLTextPane().getDocument(), 0);
getContentPane.add(MEP, BorderLayout.CENTER);

And that was it... Who thought it would be as simple as this.

Post a Comment for "Setting The Font And Style Of Jeditorpane"