Creating a small HTML-Editor using JEditorPane

Hello! I'm trying to create a small HTML-Editor. Via this editor users shall be capable to create formatted text (bold, italic, underlined, different sizes, different fonts, different colors). Furthermore, if the user pushes the enter-button a new line-break (<br>) shall be inserted. Basically my editor is working but with some big problems:
1. When I create an instance of my editor, I initialize it with some html-code.
this.m_EditorPane.setText("<html><head></head><body></body></html>"); Without this initialization between the <body> and </body> <p> and </p> will be inserted, what I don't want. But if I push now the enter-button at the beginning, <br>-tag will not be inserted in the <body>-area but in the <head>-area.
2. Styling text is working really good, but when I insert a line-break (via enter-button), the <br>-tag is inserted after the (e.g.) closing bold-tag (</b>). So, in the next line, this style-property must be reselected.
Can anybody help me to change this behavior?
Kind regards, Stefan
P.S. The way I insert the <br>-tag:
JEditorPane editor = getEditor(ae);
HTMLDocument doc = getHTMLDocument(editor);
HTMLEditorKit kit = getHTMLEditorKit(editor);
editor.replaceSelection("");
int offset = editor.getCaretPosition();
kit.insertHTML(doc, offset, "<br>", 0, 0, HTML.Tag.BR);
editor.getCaret().setDot(editor.getCaretPosition());P.P.S. Sorry for my bad english :-/

Hello! I'm trying to create a small HTML-Editor. Via this editor users shall be capable to create formatted text (bold, italic, underlined, different sizes, different fonts, different colors). Furthermore, if the user pushes the enter-button a new line-break (<br>) shall be inserted. Basically my editor is working but with some big problems:
1. When I create an instance of my editor, I initialize it with some html-code.
this.m_EditorPane.setText("<html><head></head><body></body></html>"); Without this initialization between the <body> and </body> <p> and </p> will be inserted, what I don't want. But if I push now the enter-button at the beginning, <br>-tag will not be inserted in the <body>-area but in the <head>-area.
2. Styling text is working really good, but when I insert a line-break (via enter-button), the <br>-tag is inserted after the (e.g.) closing bold-tag (</b>). So, in the next line, this style-property must be reselected.
Can anybody help me to change this behavior?
Kind regards, Stefan
P.S. The way I insert the <br>-tag:
JEditorPane editor = getEditor(ae);
HTMLDocument doc = getHTMLDocument(editor);
HTMLEditorKit kit = getHTMLEditorKit(editor);
editor.replaceSelection("");
int offset = editor.getCaretPosition();
kit.insertHTML(doc, offset, "<br>", 0, 0, HTML.Tag.BR);
editor.getCaret().setDot(editor.getCaretPosition());P.P.S. Sorry for my bad english :-/

Similar Messages

  • How to create a WYSIWIG HTML editor

    I need to create a WYSIWIG HTML editor and I'm thinking of using Swing.
    I realise many have done this before and that there are products already on the market ranging from Coffee Cup to Dreamweaver.
    However, this will be for a specific application where my users will need to drop some composite objects on to the web page -- these objects will generate chunks of HTML containing some of my own attributes with a special syntax. These objects might be as simple as a textbox with a label, or something more complex.
    So the idea is that the user selects the object they wish to create by clicking a particular icon in a palette. The cursor changes to a cross-hair as the mouse is moved across some sort of canvas pane. The user clicks where they want the top left-hand corner of the object to be (rubber banding not necessary). A dialogue pops up asking for some context-sensitive properties for the object. At this point, the system can work out the HTML object it needs to create, i.e. tags, attributes, etc.
    So far the canvas pane has acted as a simple drawing surface, perhaps with a set of grid lines to aid the user in positioning. But at this point, know that we know the HTML object required, I want it to be rendered on the pane as HTML.
    Is it possible for a pane to be both a canvas an an HTML renderer like this, so that I can achieve a true WYSIWYG effect ? Does anyone understand what I'm talking about ?! Are there any examples of how I would go about this ?
    Thanks

    Is it possible for a pane to be both a canvas an an HTML renderer like this, so that I can achieve a true WYSIWYG effect ? Does anyone understand what I'm Check out JEditorPane and JTextPane for HTML support. You have to do JEditorPane.setEditable(false) to make it render html. It also SUCKS as a web container - no support for style sheets, forms, javascript, etc.
    It is definitely possible to add components into or over the JEditorPane to show lines and other things. I'm just not sure what the point of this is.

  • Creating a WYSIWYG HTML editor

    quick question:
    I'm creating an HTML editor using JTextPane for my GUI and an HTMLEditorKit in the back. I'm just running a simple test with the following html file:
    <html>
      <head>
      </head>
      <body>
        <p>
          let's make a web page
        </p>
        <p>
        </p>
        <p>
          <b>just to see if this works</b>
        </p>
      </body>
    </html>I'm calling
    HTMLEditorKit editorKit = new HTMLEditorKit();
    HTMLDocument doc = (HTMLDocument) editorKit.createDefaultDocument();
    editorKit.read(m_reader, this.getDoc(), 0);where m_reader is a FileReader linked to the above file.
    Then I'm using that as the content for my JTextPane by saying
    textPane = new JTextPane(doc);Then when I do a System.out.print(textPane.getText()), I get:
    <html>
      <head>
      </head>
      <body>
        <p>
        </p>
      </body>
    </html>any ideas?

    Originally posted by: aullah.thinkanalytics.com
    Jai Kejriwal wrote:
    > I am trying to create a WYSIWYG HTML editor. For text boxes, I thought it
    > would
    > be best to use the swt text widget that could be dragged and dropped.
    > However,
    > the text widget needs to have a Composite that it can be added on to. Does
    > this
    > mean that I will have to create my own visual representation of a text
    > widget by
    > extending the Figure class?
    > Also, if you all have any experience/ideas of how I should proceed with
    > creating a WYSIWYG
    > HTML editor, I welcome your input. Particularly, what layout should I use
    > for the base page,
    > and how should I handle code generation. I am a newbie so the help means a
    > lot.
    I'd create my own Draw2D figure to render text boxes and other html
    elements. SWT widgets can't (as far as I know) be embedded in the GEF
    GrapicalViewer's main (SWT) control. You're building blocks are Draw2D
    figures. A nice emulated lightweight solution (c.f swing).
    The other great advantage, is that a figure based TextField gives you the
    the ability to style the appearance of the textbox, ie border, colour, etc.
    You could create a base figure styling interface.
    The TextField or TextBox, could be based on a draw2d.text FlowFigure.
    You're also going to need to have some form of FlowLayout for the page,
    to emulate how elements flow on a HTML page in a browser.
    I guess the Logic Diagram labels are a good place to start looking.

  • How to create a small HTML-file in Applet

    What i wan't to do is as follows:
    1. In an applet i create a string containing a small HTML-file. Its contents depends on what the user chose in the applet.
    2. then i wan't to redirect the browser to that HTML-file. appletcontext.showDocument(URL) could be used.
    The problem is how can i create an URL to a string which is only in memory.
    Writing the string to a file and then creating URL to it poses problems, as we all know, writing files from applets is difficult.
    Any help would be appreciated.

    Here is how you do it:
    1) use the JSObject (you may have to import
    netscape.javascript.JSObject depending on the
    version of your SDK) to open a window with an empty
    URL, a title , and a _blank or _self
    target.
    2) use the JSObject document.write to write the HTML
    string to the window that you opened in #1 above
    3) close the document.
    If you need further assistance, post your code and I
    can modify it for you or if you want, I can whip up a
    small demo applet for you to try.
    ;o)
    V.V.Thanks!! Your post has been very helpful. One question though, I suppose the client has to have a java-plug-in installed in his/her web-browser, is that right?

  • Is it possible to write an HTML editor using Java?

    I have this final year project (for my degree), where I need to use Java to write an HTML editor.
    It doesn't have to be fancy or anything, just need to be able to generate HTML files from the GUI frontend where text, images and tables will be created.
    I'm new to Java, and I'm having problem with it.
    Please help, I only need to know whether it's possible, and possible a little guideline on how to go about it, please?
    Terry

    http://www.hexidec.com/ekit.php

  • Creating a PHP/HTML Editor

    I'm doing a school project on a PHP/HTML Editor.
    I'm looking for some help on finding a good tutorial on changing properties to a JEditorPane. I want to set up the indent size, colors for tags, comments, statements, etc...
    anyone help??

    Here, I stole this code from the advanced forum on Saturday and tried to develop it, though gave up when I couldn't get setTabs or load file to work and tooltips was too damn slow.
    I had an idea that I could use it to run javac and to execute Frames and Applets with it ... right now I'm reconfiguring the design and thinking about dropping the highlighter altogether, but thats my story. Still it may be useful /may give you ideas /may be just the base or platform you're looking for.import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import java.io.*;
    class Highlighter extends DefaultStyledDocument{
         private DefaultStyledDocument doc;
         private Element rootElement;
         private boolean multiLineComment;
         private MutableAttributeSet normal;
         private MutableAttributeSet keyword;
         private MutableAttributeSet comment;
         private MutableAttributeSet quote;
         private MutableAttributeSet tabSpace;
         private Hashtable keywords;
    public Highlighter(){
           doc = this;
         rootElement = doc.getDefaultRootElement();
         putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n" );
         normal = new SimpleAttributeSet();
         StyleConstants.setForeground(normal, Color.black);
         comment = new SimpleAttributeSet();
         StyleConstants.setForeground(comment, Color.green);
         StyleConstants.setItalic(comment, true);
         keyword = new SimpleAttributeSet();
         StyleConstants.setForeground(keyword, Color.blue);
         quote = new SimpleAttributeSet();
         StyleConstants.setForeground(quote, Color.red);
         Object dummyObject = new Object();
         keywords = new Hashtable();
         keywords.put( "abstract", dummyObject );
         keywords.put( "boolean", dummyObject );
         keywords.put( "break", dummyObject );
         keywords.put( "byte", dummyObject );
         keywords.put( "byvalue", dummyObject );
         keywords.put( "case", dummyObject );
         keywords.put( "cast", dummyObject );
         keywords.put( "catch", dummyObject );
         keywords.put( "char", dummyObject );
         keywords.put( "class", dummyObject );
         keywords.put( "continue", dummyObject );
         keywords.put( "default", dummyObject );
         keywords.put( "do", dummyObject );
         keywords.put( "double", dummyObject );
         keywords.put( "else", dummyObject );
         keywords.put( "extends", dummyObject );
         keywords.put( "false", dummyObject );
         keywords.put( "final", dummyObject );
         keywords.put( "finally", dummyObject );
         keywords.put( "float", dummyObject );
         keywords.put( "for", dummyObject );
         keywords.put( "if", dummyObject );
         keywords.put( "implements", dummyObject );
         keywords.put( "import", dummyObject );
         keywords.put( "instanceof", dummyObject );
         keywords.put( "int", dummyObject );
         keywords.put( "interface", dummyObject );
         keywords.put( "long", dummyObject );
         keywords.put( "new", dummyObject );
         keywords.put( "null", dummyObject );
         keywords.put( "package", dummyObject );
         keywords.put( "private", dummyObject );
         keywords.put( "protected", dummyObject );
         keywords.put( "public", dummyObject );
         keywords.put( "return", dummyObject );
         keywords.put( "short", dummyObject );
         keywords.put( "static", dummyObject );
         keywords.put( "super", dummyObject );
         keywords.put( "switch", dummyObject );
         keywords.put( "synchronized", dummyObject );
         keywords.put( "this", dummyObject );
         keywords.put( "throw", dummyObject );
         keywords.put( "throws", dummyObject );
         keywords.put( "transient", dummyObject );
         keywords.put( "true", dummyObject );
         keywords.put( "try", dummyObject );
         keywords.put( "void", dummyObject );
         keywords.put( "volatile", dummyObject );
         keywords.put( "while", dummyObject );
    * Override to apply syntax highlighting after the document has been updated
       public void insertString(int offset, String str, AttributeSet a)
                                            throws BadLocationException{
              if (str.equals("{"))
              str = addMatchingBrace(offset);
              super.insertString(offset, str, a);
              processChangedLines(offset, str.length());
    * Override to apply syntax highlighting after the document has been updated
       public void remove(int offset, int length) throws BadLocationException{
              super.remove(offset, length);
              processChangedLines(offset, 0);
    * Determine how many lines have been changed,
    * then apply highlighting to each line
       private void processChangedLines(int offset, int length)
                                    throws BadLocationException {
              String content = doc.getText(0, doc.getLength());
              // The lines affected by the latest document update
              int startLine = rootElement.getElementIndex( offset );
              int endLine = rootElement.getElementIndex( offset + length );
              // Make sure all comment lines prior to the start line are commented
              // and determine if the start line is still in a multi line comment
              setMultiLineComment( commentLinesBefore( content, startLine ) );
              // Do the actual highlighting
                   for (int i = startLine; i <= endLine; i++){
                        applyHighlighting(content, i);
          // Resolve highlighting to the next end multi line delimiter
              if (isMultiLineComment())commentLinesAfter(content, endLine);
              else highlightLinesAfter(content, endLine);
    * Highlight lines when a multi line comment is still 'open'
    * (ie. matching end delimiter has not yet been encountered)
         private boolean commentLinesBefore(String content, int line){
              int offset = rootElement.getElement( line ).getStartOffset();
              // Start of comment not found, nothing to do
              int startDelimiter = lastIndexOf( content, getStartDelimiter(), offset-2);
              if (startDelimiter < 0)return false;
              // Matching start/end of comment found, nothing to do
              int endDelimiter = indexOf( content, getEndDelimiter(), startDelimiter );
              if (endDelimiter < offset & endDelimiter != -1)return false;
              // End of comment not found, highlight the lines
              doc.setCharacterAttributes(startDelimiter, offset - startDelimiter + 1, comment, false);
              return true;
    * Highlight comment lines to matching end delimiter
         private void commentLinesAfter(String content, int line){
              int offset = rootElement.getElement( line ).getEndOffset();
              // End of comment not found, nothing to do
              int endDelimiter = indexOf( content, getEndDelimiter(), offset );
              if (endDelimiter < 0) return;
              // Matching start/end of comment found, comment the lines
              int startDelimiter = lastIndexOf( content, getStartDelimiter(), endDelimiter );
                   if (startDelimiter < 0 || startDelimiter <= offset){
                        doc.setCharacterAttributes(offset, endDelimiter - offset + 1, comment, false);
    * Highlight lines to start or end delimiter
         private void highlightLinesAfter(String content, int line)
                                                                throws BadLocationException{
              int offset = rootElement.getElement( line ).getEndOffset();
              // Start/End delimiter not found, nothing to do
              int startDelimiter = indexOf( content, getStartDelimiter(), offset );
              int endDelimiter = indexOf( content, getEndDelimiter(), offset );
              if (startDelimiter < 0)     startDelimiter = content.length();
              if (endDelimiter < 0)endDelimiter = content.length();
              int delimiter = Math.min(startDelimiter, endDelimiter);
              if (delimiter < offset)return;
              // Start/End delimiter found, reapply highlighting
              int endLine = rootElement.getElementIndex( delimiter );
                   for (int i = line + 1; i < endLine; i++){
                        Element branch = rootElement.getElement( i );
                        Element leaf = doc.getCharacterElement( branch.getStartOffset() );
                        AttributeSet as = leaf.getAttributes();
                        if ( as.isEqual(comment) )applyHighlighting(content, i);
    * Parse the line to determine the appropriate highlighting
         private void applyHighlighting(String content, int line)
                                                             throws BadLocationException{
              int startOffset = rootElement.getElement( line ).getStartOffset();
              int endOffset = rootElement.getElement( line ).getEndOffset() - 1;
              int lineLength = endOffset - startOffset;
              int contentLength = content.length();
                   if (endOffset >= contentLength)endOffset = contentLength - 1;
              // check for multi line comments
              // (always set the comment attribute for the entire line)
                 if (endingMultiLineComment(content, startOffset, endOffset)
                ||isMultiLineComment()||startingMultiLineComment(content, startOffset, endOffset)){
                         doc.setCharacterAttributes(startOffset, endOffset - startOffset + 1, comment, false);
                         return;
              // set normal attributes for the line
              doc.setCharacterAttributes(startOffset, lineLength, normal, true);
              // check for single line comment
              int index = content.indexOf(getSingleLineDelimiter(), startOffset);
                   if ( (index > -1) && (index < endOffset) ){
                        doc.setCharacterAttributes(index, endOffset - index + 1, comment, false);
                        endOffset = index - 1;
              // check for tokens
              checkForTokens(content, startOffset, endOffset);
    * Does this line contain the start delimiter
         private boolean startingMultiLineComment(String content, int startOffset, int endOffset)
                                                                                                              throws BadLocationException{
              int index = indexOf( content, getStartDelimiter(), startOffset );
                   if ( (index < 0) || (index > endOffset) )return false;
                   else{
                        setMultiLineComment( true );
                        return true;
    * Does this line contain the end delimiter
         private boolean endingMultiLineComment(String content, int startOffset, int endOffset)
                                                                                                             throws BadLocationException{
              int index = indexOf( content, getEndDelimiter(), startOffset );
                   if ( (index < 0) || (index > endOffset) )return false;
                   else{
                        setMultiLineComment( false );
                        return true;
    * We have found a start delimiter
    * and are still searching for the end delimiter
         private boolean isMultiLineComment(){
              return multiLineComment;
         private void setMultiLineComment(boolean value){
              multiLineComment = value;
    * Parse the line for tokens to highlight
         private void checkForTokens(String content, int startOffset, int endOffset){
              while (startOffset <= endOffset){
              // skip the delimiters to find the start of a new token
                   while (isDelimiter(content.substring(startOffset, startOffset+1))){
                        if (startOffset < endOffset)startOffset++;
                        else return;
              // Extract and process the entire token
              if (isQuoteDelimiter( content.substring(startOffset, startOffset + 1)))
                   startOffset = getQuoteToken(content, startOffset, endOffset);
              else startOffset = getOtherToken(content, startOffset, endOffset);
         private int getQuoteToken(String content, int startOffset, int endOffset){
              String quoteDelimiter = content.substring(startOffset, startOffset + 1);
              String escapeString = getEscapeString(quoteDelimiter);
              int index;
              int endOfQuote = startOffset;
              // skip over the escape quotes in this quote
              index = content.indexOf(escapeString, endOfQuote + 1);
                   while ( (index > -1) && (index < endOffset) ){
                        endOfQuote = index + 1;
                        index = content.indexOf(escapeString, endOfQuote);
              // now find the matching delimiter
              index = content.indexOf(quoteDelimiter, endOfQuote + 1);
                   if ( (index < 0) || (index > endOffset) )endOfQuote = endOffset;
                   else endOfQuote = index;
              doc.setCharacterAttributes(startOffset, endOfQuote-startOffset+1, quote, false);
         return endOfQuote + 1;
         private int getOtherToken(String content, int startOffset, int endOffset){
              int endOfToken = startOffset + 1;
              while (endOfToken <= endOffset ){
                   if (isDelimiter(content.substring(endOfToken, endOfToken+1)))break;
                   endOfToken++;
              String token = content.substring(startOffset, endOfToken);
                   if ( isKeyword( token ) )
                        doc.setCharacterAttributes(startOffset, endOfToken-startOffset, keyword, false);
              return endOfToken + 1;
    * Assume the needle will the found at the start/end of the line
         private int indexOf(String content, String needle, int offset){
              int index;
                   while ( (index = content.indexOf(needle, offset)) != -1 ){
                        String text = getLine( content, index ).trim();
                             if (text.startsWith(needle) || text.endsWith(needle))break;
                             else offset = index + 1;
              return index;
    * Assume the needle will the found at the start/end of the line
         private int lastIndexOf(String content, String needle, int offset){
              int index;
              while ( (index = content.lastIndexOf(needle, offset)) != -1 ){
                   String text = getLine( content, index ).trim();
                        if (text.startsWith(needle) || text.endsWith(needle))break;
                        else offset = index - 1;
              return index;
         private String getLine(String content, int offset){
              int line = rootElement.getElementIndex( offset );
              Element lineElement = rootElement.getElement( line );
              int start = lineElement.getStartOffset();
              int end = lineElement.getEndOffset();
              return content.substring(start, end - 1);
    * Override for other languages
         protected boolean isDelimiter(String character){
              String operands = ";:{}()[]+-/%<=>!&|^~*";
                   if (Character.isWhitespace( character.charAt(0) ) ||
                                            operands.indexOf(character)!= -1 ) return true;
                   else return false;
    * Override for other languages
         protected boolean isQuoteDelimiter(String character){
              String quoteDelimiters = "\"'";
                   if (quoteDelimiters.indexOf(character) < 0) return false;
                   else return true;
    * Override for other languages
         protected boolean isKeyword(String token){
              Object o = keywords.get( token );
              return o == null ? false : true;
    * Override for other languages
         protected String getStartDelimiter(){
              return "/*";
    * Override for other languages
         protected String getEndDelimiter(){
              return "*/";
    * Override for other languages
         protected String getSingleLineDelimiter(){
              return "//";
    * Override for other languages
         protected String getEscapeString(String quoteDelimiter){
              return "\\" + quoteDelimiter;
         protected String addMatchingBrace(int offset) throws BadLocationException{
              StringBuffer whiteSpace = new StringBuffer();
              int line = rootElement.getElementIndex( offset );
              int i = rootElement.getElement(line).getStartOffset();
                   while (true){
                        String temp = doc.getText(i, 1);
                             if (temp.equals(" ") || temp.equals("\t")){
                                  whiteSpace.append(temp);
                                i++;
                             else break;
              return "{\n" + whiteSpace.toString() + "\t\n" + whiteSpace.toString() + "}";
    public class MyJavac extends JFrame implements ActionListener{
       JPanel top, main;
         JEditorPane edit = new JEditorPane();
       Highlighter syntax = new Highlighter();
       JButton []buts = new JButton[7];
       String theText="";
    public MyJavac(){
       super("Java Based Text Editor");
       getContentPane().setLayout(new BorderLayout() );
       String []str = {"New","Open","Save","Save As","Compile","J/Frame","Applet"};
       String []tooltips = {"<html><center>Open a new <br>java file</center></html>",
                            "<html><center>Open an existing<br>java file</center></html>",
                            "<html><center>Save java<br>file</center></html>",
                            "<html><center>Save java file<br>with new filename</center></html>",
                            "<html><center>Run the javac<br>DOS compiler</center></html>",
                            "<html><center>Run java JFrame<br>or Frame application</center></html>",
                            "<html><center>Run java Applet<br>html application</center></html>"};
       top = new JPanel();
       top.setLayout(new GridLayout(1,7,5,0) );
       JPanel east = new JPanel();
       JPanel west = new JPanel();
          for(int i=0; i<buts.length; i++){
             buts[i] = new JButton(str);
    buts[i].setToolTipText(tooltips[i]);
    buts[i].addActionListener(this);
    top.add(buts[i]);
    main = new JPanel();
    main.setLayout(new GridLayout(1,1) );
         edit.setEditorKit(new StyledEditorKit());
         edit.setDocument(syntax);
         JScrollPane scroll=new JScrollPane(edit);
    main.add(scroll);
    getContentPane().add("North",top);
    getContentPane().add("Center",main);
    public void actionPerformed(ActionEvent e){
    String option = e.getActionCommand();
    if(option.equals("New")){}
    if(option.equals("Open")) {
    JFileChooser chooser = new JFileChooser();
    int returnVal = chooser.showOpenDialog(this);
    if(returnVal == JFileChooser.APPROVE_OPTION);
    try {
    getFromFile();
    catch(Exception f){
    String error1= "Error opening the file ";
    String error2 = "or the file was not found";
    JOptionPane.showMessageDialog(null, error1 +"\n" + error2);
    edit.setText(theText);
    public void getFromFile() throws Exception{
    int reader = 0;
    theText = "";
    FileReader in = new FileReader("junk.txt");
    do {
    reader = in.read();
    theText += (char)reader;
    } while (reader != -1);
    in.close();
    public static void main(String args[]){
    MyJavac jav = new MyJavac();
         Image onFrame = Toolkit.getDefaultToolkit().getImage("flag.gif") ;
    jav.setIconImage(onFrame);
         jav.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
         jav.setSize(600,400);
         jav.setVisible(true);

  • How to create hyperlink in Html page using Java

    Hello every one
    I want to know that how can I create a hyperlink in Html page using java ?
    Let for example
    I have code like this and i want to give hyperlink to it using java.
    rember that i am creating node using this id="name" which give me multiple value. and i want to assign diff link to each name..?
    <tr>
    <td ><span id="name"></span>
    </tr>

    but i m using this code to create node in html file
    HTMLLIElement li = (HTMLLIElement)appHTML.createElement("LI");
    Text txt = appHTML.createTextNode(name);
    li.appendChild(txt);
    appHTML.getElementById("name").appendChild(li);
    this will display all name value which is coming from database,
    and i want to assign a hyperlink to it,
    I have id with name also so I thought that using id i will
    create javascript like
    function popup(id)
         if(id==1)
              var n1 = window.open("../list/name1.html");
         if(id==2)
              var n1 = window.open("../list/name2.html");
    this way i want to popup particular file if i can pass id value in this function
    so want hyperlink like
    name

  • How to show an html page using JEditorPane in applet.

    I have never use jeditorpane with applet so i dont know how to show a html page.if you have some code or any example then please posted that.Thanks

    public class MyApplet extends JApplet{
        private JTextPane textPane = null;
        public void init(){
        HTMLEditorKit editorKit = new HTMLEditorKit();
        HTMLDocument  htmlDoc   = (HTMLDocument)editorKit.createDefaultDocument();
        textPane  = new JTextPane();
        textPane.setEditable(false);
        textPane.setEditorKit(editorKit);
        textPane.setContentType("text/html");
        textPane.setDocument(htmlDoc);
        Container c = getContentPane();
        c.add(new JScrollPane(textPane),    BorderLayout.CENTER);
        c.add(buttonPanel,                  BorderLayout.SOUTH);
        c.add(Box.createVerticalStrut(5),   BorderLayout.NORTH);     
        c.add(Box.createHorizontalStrut(5), BorderLayout.EAST);     
        c.add(Box.createHorizontalStrut(5), BorderLayout.WEST);
        public void setHtml(String html){
            // you should check the textpane's document to detrmine if there
            // is already text in there..if so, then clear the textpane text and then
            // set the new html...Note: JTextPane only show basic Html ..
            // not like a full blown browser
            textPane.setTextt(html);
            textPane.setCaretPosition(0);
    }

  • Creating html table using FLEX

    Hi
    I am new to flex,can any one help me how to create a simple
    html table using flex.
    regards
    pr@veen

    "callpraveenin1973" <[email protected]>
    wrote in message
    news:goj5qq$hgm$[email protected]..
    > Hi
    > I am new to flex,can any one help me how to create a
    simple html table
    > using flex.
    What would you use it for?

  • Disple html using JEditorPane

    I want display html file using JEditorPane
    but I become an exception
    java.net.MalformedURLException: unknown protocol: e
    what schould be the problem
           import javax.swing.*;
           import java.net.URL;
           import java.io.File;
    public class Browser extends JFrame
          JEditorPane  ePane = new JEditorPane();
          public Browser(){
              this.setBounds(200,50,700,650);
              this.setLayout(null);
              ePane.setBounds(50,20, 600,500);
              try {
                       File file = new File("xx.html");
                       String ss = file.getAbsolutePath();
                     URL url = new URL(ss);
                     ePane.setPage(url);
                 } catch (java.io.IOException ex) { ex.printStackTrace(); }
              this.add(ePane);
    }  

                   File file = new File("xx.html");"xx.html" lacks a protocol, like "http" or "ftp". But anyway, why not just use File.toURL()?

  • Wrong behaviour in link generated by HTML editor

    Hi all,
    anybody knows if there is some bug in HTML editor used in XML Form Builder projects?
    We are facing the following problem:
    1) we create a link by filling the html editor area in a news XML edit form
    2) save and publish the news
    3) in rendering of the news the link doesn't respect the CSS class used for links (e.g. the link is a standard link, blue and underline)
    Is it a standard behaviour or not?
    Thanks
    Marta

    Hi all,
    anybody knows if there is some bug in HTML editor used in XML Form Builder projects?
    We are facing the following problem:
    1) we create a link by filling the html editor area in a news XML edit form
    2) save and publish the news
    3) in rendering of the news the link doesn't respect the CSS class used for links (e.g. the link is a standard link, blue and underline)
    Is it a standard behaviour or not?
    Thanks
    Marta

  • Creating a small business website...

    Hello! I would like to create a small business website using iweb. I created something simple, and I am happy with it, but I was wondering if anyone knew how I could use it with a regular website address (www.company.com) instead of web.mac.com/company and still use iweb. Any tips or advice would be great. Thanks!

    http://www.varkgirl.com/iWebFAQ/FAQ%20Home/EFC18081-F59F-4EEA-AA5F-0DB97AAA30D6. html

  • Can't get FCKeditorAPI to load to validate HTML Editor contents

    I have an HTML Editor item on my page and wanted to quickly check the length of the text in the editor before submitting the page. It should be possible to get the contents of the HTML Editor using the FCKeditorAPI, but I can't get it to load. I'm doing this by putting basically this in the HTML header:
    <script type="text/javascript">
    function checkLength() {
    var oEditor = FCKeditorAPI.GetInstance('MY_EDITOR');
    alert(oEditor.GetXHTML.length);
    </script>
    Then calling the function when the Save button is clicked. I'm only geting "FCKeditorAPI is not defined" errors, however.

    Hi,
    I have the same problem, because I want to check the number of characters in the editor field before the values are stored.
    And when I tried to get the value of the fckeditor field with document.getElementById(XXX).value; I don`t get the actual value.
    So I have to get the value through the instance of the fckeditor.
    Thanks for your help,
    Tim

  • Xml form HTML Editor control change.

    Hi,
    Is it possible to change External weblink control property of HTML Editor used in xml form builder.?
    As of now this control gives 2 options to provide external weblink (1.Open in active window ,2.open in new window).I want to add open in same window as top.
    Can anyone give some useful information ?
    Thanks and Regards,
    Jack.
    Note: Points will be awarded for useful answers.

    Hi jack men,
    If you are still interested in a solution to your problem...
    We just hit upon the same problem. I found out that XMLForms reference htmledit4.js in their <XMLForm-Name>Edit.xsl, so you have to adapt that one.
    I saved htmledit4.js and renamed it to htmledit5.js so that I can change the HTMLEditor settings only for my XMLForm (and not for e.g. SAPNewsForm).
    I changed the entry in my XML-Form Editor settings XSL to reference the new JavaScript file:
    [code]<xsl:value-of select="$xmlformsroot"/>/htmledit/htmledit5.js</xsl:if>[/code]
    Then I copied the method body of htmledit3.js (the standard htmleditor JavaScript file) to htmledit5.js and adapted it to just show the two tragets of <i>self</i> and <i>top</i>.
    The method to display link properties is: <b>htmlb_hed_makeWebLinkDialog</b>
    Find this method in both files. Then find in htmledit3.js the beginning of the target window selection-box:
    [code]sSizerHtml += "<SELECT id=htmlb_hed_link_launch_mode class=\"urDdlWhlSml\">";[/code]
    the following lines of code determine the selectable values.
    You will notice that htmledit4.js misses a few entries. Just copy all or the ones you need.
    For your convenience I show my code here:
    [code]  sSizerHtml += "<td>";
      sSizerHtml += "<span style=\"font-size:1em;\">";
      sSizerHtml += "<SELECT id=htmlb_hed_link_launch_mode class=\"urDdlWhlSml\">";
    //-- target=_blank
      sSizerHtml += "<OPTION value=\"_blank\" ";
      if(modOpenMode==1) sSizerHtml += "selected";
      sSizerHtml += ">";
      sSizerHtml += txtMap["TXT_HTMLB_HED_BLANK"]; 
      sSizerHtml += "</OPTION>";
    //-- target=_parent --
      sSizerHtml += "<OPTION value=\"_parent\" ";
      if(modOpenMode==2) sSizerHtml += "selected";
      sSizerHtml += ">";
      sSizerHtml += txtMap["TXT_HTMLB_HED_PARENT"]; 
      sSizerHtml += "</OPTION>";
    //-- target=_search--
      sSizerHtml += "<OPTION value=\"_search\" ";
      if(modOpenMode==3) sSizerHtml += "selected";
      sSizerHtml += ">";
      sSizerHtml += txtMap["TXT_HTMLB_HED_SEARCH"]; 
      sSizerHtml += "</OPTION>"; 
    //--target=_self
      sSizerHtml += "<OPTION value=\"_self\" ";
      if(modOpenMode==4) sSizerHtml += "selected";
      sSizerHtml += ">";
      sSizerHtml += txtMap["TXT_HTMLB_HED_SELF"]; 
      sSizerHtml += "</OPTION>";
    //-- target=_top
      sSizerHtml += "<OPTION value=\"_top\" ";
      if(modOpenMode==5) sSizerHtml += "selected";
      sSizerHtml += ">";
      sSizerHtml += txtMap["TXT_HTMLB_HED_TOP"]; 
      sSizerHtml += "</OPTION></SELECT></span>";
      sSizerHtml += "</td>";
      sSizerHtml += "</tr>";[/code]
    I didn't check yet if a new generation of the XMLForms Project in the XMLFormsBuilder overwrites the changes in the XMLFormsEdit.xsl, however I guess so. A better way would be to adjust the JavaScript reference in some other configuration file that I haven't found yet, until then just adapt the XSL everytime...
    If Carsten Buechert contacted you regarding the exchange of the whole control, I would be interested myself as well.
    Cheers
    Kilian

  • WYSIWYG HTML Editor code

    I was reading a lot of old messages in this forum and there was some about people who had created a WYSIWYG HTML Editor. They were willing to share the code. I'm insteresting in how a good such editor are build... Is there anyone who wants to share such an editor to me?

    I'm insteresting in how a good such editor are build...
    Is there anyone who wants to share such an editor to me?The HTML-Editor Ekit is under the Gnu Public Licence.
    You can download the source code from their website:
    http://www.hexidec.com/ekit.php
    Did you search such a thing?
    Marcus

Maybe you are looking for