File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes WYSIWYG  Editors in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "WYSIWYG  Editors in java" Watch "WYSIWYG  Editors in java" New topic
Author

WYSIWYG Editors in java

merwin pinto
Ranch Hand

Joined: Feb 16, 2005
Posts: 39
Hi,
is there a simple way to write a WYSIWYG (What u see is what u get editor)
using java swings .... i tried wit JTextPane ..editor pane ..but no luck
does any one have the code for it ... or a logic as to how to embed styles so that the text gets formatted as we type ..
thanks a lot
Jared Cope
Ranch Hand

Joined: Aug 18, 2004
Posts: 243
Hi,

Yes, can be done. You need to use JTextPane and then most probably create your own DefaultStyledDocument object that the Pane uses. The trick is to subclass these classes and provide your own custom behaviour and styles where necessary.

Its a bit of a hard slog to get up to speed on it all, but you have to know all about the insertString and remove methods in the Document object to be able to do anything useful.

I suggest that you set aside a couple of hours and go through Suns Text componant tutorial and run the webstart apps to get a feel for what is possible. Use this link:

http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html

Cheers, Jared.


SCJP 1.4 91%, SCJP 1.5 88%, SCJD B&S
Hans Oesterholt
Greenhorn

Joined: Apr 28, 2013
Posts: 2
You can begin with JRichTextEditor and develop further.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42913
    
  68
Hans, welcome to JavaRanch!

I have to say, you're optimistic that an answer will still be relevant 8 years after the fact
Hans Oesterholt
Greenhorn

Joined: Apr 28, 2013
Posts: 2
Oops
Keith Spriggs
Greenhorn

Joined: Jul 19, 2012
Posts: 18
There is another way
Look at the window builder add on for eclipse it gives very good wysiwyg editor.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WYSIWYG Editors in java