• Post Reply Bookmark Topic Watch Topic
  • New Topic

creating HTML Editor in Swing

 
Susmita Tripathy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to develop a GUI, where the text area should act like a basic HTML Editor. I am not very familiar with Swing, but found that the JEditorPane can be used to create customized Editor and supports HTML Editors.
Could anybody give me some pointer as to how to go about it. Is it possible? We do not need a fancy editor, but a very basic one.
I would really appreciate any kind of help, pointers and suggestions.
Thanks a lot,
Susmita
 
Stanley George
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi susmita
u r right about using JEditorPane
do u just want to view HTML pages or do u want to to modify them
also?
viewing is simple...if u wanna edit things become a bit complex
assuming that u will start with viewing pages i'll give u a
starter...

jt = new JEditorPane;
jt.setEditable (true); // if u wanna edit pages
// you want to follow the links
jt.addHyperlinkListener(new HyperlinkListener () {
public void hyperlinkUpdate(final HyperlinkEvent e) {
if (e.getEventType() ==
HyperlinkEvent.EventType.ACTIVATED) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
//get the url of the link
URL url = e.getURL();
}
//open link
showPage(urlString);
}
} catch (Exception e) {
// display error message
JOptionPane.showMessageDialog (
Browser.this, "Can't follow link",
"Invalid Input",
JOptionPane.ERROR_MESSAGE);
}
}
});
}
}
});
 
Susmita Tripathy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your reply George.
I want editing and entering text in HTML format, from the GUI.
I would really appreciate any kind of input to be able to do the same.
Thanks again,
Susmita
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you mean by "entering and editing text in HTML format". Can you not just type in the HTML, the same as you can in any other editor? What else do you want this to do?
 
Susmita Tripathy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like the user to be able create HTMl pages, giving him/her the ability to insert links, tables, headings etc. Something like a miniature Netscape Composer, supplying a limited subset of the HTML TAGS.
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Well I need to develop a GUI that lets a User enter text modify the same, and on a click of a button view the HTML source of the document he just created.
in Short a HTML editor, like frontpage editor, in Java.
or more specifically, since the iFrame tag doesnt work on Netscape a substitute for that.
Please guide me on this.
Regds
Gautham Kasinath
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I'm a little confused about what is needed here. Do you want to build a web page design app (WYSIWYG, where you actually design the page and then convert it to HTML - i think that would be a very very big task :eek , or do you just want to make a text editor with a few special HTML features, such as a library of tags? I have made something like the later of these that just inserts tags as selected from a menu, and I used JTextPane.
regards,
Ben.
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't mind spending some money, I recommend Core Swing Advanced Programmer by Kim toply as it contains more info on using the JEditorPane to do wysiwyg style html editing than any other book I could find.
Marcus
------------------
http://www.jchq.net Mock Exams, FAQ, Tutorial, Links, Book reviews
=================================================
Almost as good as JavaRanch
=================================================
 
Joe Gilvary
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a GPL'd HTML Editor in Java available at http://www.hexidec.com/
If it's not everything you need, you can still work
from its source.
Thanks,
Joe
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!