JEditorPane setText problems

I'm having problems in setting styles after using setText with JEditorPane.
For example I enter a line of text in the JEditorPane, highlight this in bold and then save it back to file. I then load this line of text back into the JEditorPane using the setText method and I see my highlighted line of bold text. I then go to unmark the bold highlighting of the line and this appears to have been done correctly but when I go to view the contents of the JEditorPane's document I find that the bold hasn't actually been removed from the content but it appears to have done so looking at the JEditorPane.
Has anyone else had this problem?
I have found someone who has described a very similar problem at the following link
http://groups.google.com/groups?q=jeditorpane+setText&hl=en&selm=3B7BEBD2.24EE2EE8%40home.com&rnum=6

I've had this Problem when I was building a HTML-Editor-Applet.
The Problem was, that there was a Style-Attribute like e.g. text-decoration:underlined. If I removed the underlined style the Attribut was text-decoration:none, but the getText() method just cared about the Style with the name text-decoration to handle this Element as underlined. I had to build my own getText() method by examing all the Elemntes from the Document and set the html-Tags for the style-attributes.
Jörn

Similar Messages

  • JEditorPane, setText, and redraw problems.

    This code was borrowed from another post on the forum. The aim is to append lines of text onto the bottom of the editor pane.
        JEditorPane messagePane = new JEditorPane("text/html", "");
        String text = messagePane.getText();
        text = text.substring(text.indexOf("<body>") + 6, text.indexOf("</body>"));
        text = text + "<br>" + message;
        messagePane.setText(text);It works, but the whole editor pane flashes when setText is called.
    Is there anything I can do to prevent this? I've tried setDoubleBuffered(true) but that doesn't seem to work.
    There are a whole lot of methods on HTMLDocument like insertBeforeEnd which should allow me to insert content before the end body tag, but they don't work anyway.

    I've encoutered this problem and I use the following to replace the call to setText, actually this call causes the flicker effect you experience (for some obscure reason involving callbacks and property change)
            String myString = "<html><body>Sample text, put yours here</body></html>";
            EditorKit kit = this.messagePane.getEditorKit();
            Document newDocument = kit.createDefaultDocument();
            StringReader reader = new StringReader(myString);
            try
                kit.read(reader, newDocument, 0);
                this.messagePane.setDocument(newDocument);
            catch (Exception e)
                this.messagePane.setText("Error " + e);
            }Et voil�, no more flickering !

  • JEditorPane setText 2MB HTML --- Terrible Performance !!! (65 seconds)

    I'm trying to load an HTML file that is large approximately 2MB (1927KB for the sake of precision) into a JEditorPane, and it takes about 65 seconds, it seems to be a bug of the JTextPane/JEditorPane, i have read also several articles on the web like [this one|http://java-sl.com/JEditorPanePerformance.html] , but i couldn't find a solution ...
    Here's the code that i use :
    final String htmlContent = //Load a 2MB String
    previewPane.setContentType("text/html; charset=UTF-8");
    previewPane.setText(htmlContent);
    The setText method takes about 65seconds to get completely executed as you can see in my application log :
    Set the html content(1927KB) of the Preview pane, loading time=68230ms
    Set the html content(1927KB) of the Preview pane, loading time=62693ms
    Set the html content(1927KB) of the Preview pane, loading time=66583ms
    Is there a way to solve this problem ?
    About 65 seconds to load 2MB of Text is a terrible performance on an Intel Core 2 Duo 2.93GHz with 8GB of DDR 3 RAM ...

    Remember that this data not only needs to be loaded, it also needs to be interpreted and rendered. I have a sneaky suspicion that the slowdown is actually in the rendering part. It is not a huge amount of bytes - it is a huge amount of HTML content that needs to be processed. Modern browsers can cope with that no problem, but JEditorPane is not a browser.
    It could be a performance issue, but that won't help you anything. Even if you would create a bug report it probably won't ever get a high enough priority that it will be considered for fixing; Swing isn't exactly actively developed anymore. On top of that I always saw the HTML capabilities of JEditorPane as a novelty really; nice that an attempt has been made to make it somewhat easier to load formatted text into it, but don't start treating or making expectations of it like you would of a web browser.
    There is a test you can do. Assuming you are running under Windows, try turning off Direct3D and see if that influences the performance. In other discussions I have seen that the rendering of text is actually a performance hog when hardware rendering is enabled, for whatever reason. You do this by starting Java with the following command line switch:
    -Dsun.java2d.d3d=false
    Edited by: gimbal2 on Feb 1, 2012 3:57 AM

  • Memory leak in Jeditorpane.setText method while displaying html content

    I tried to display a larger size html page using JeditorPane. But I found that there as a huge memory leak after JEditorPane's setText method was called.
    Refering to the below code there was a difference of about 40 MB after the setText method was called.This does not happen if we display the page in rtf format.This finally results in Out Of memry error.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    import java.awt.BorderLayout;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    public class SampleProgram extends JFrame{
    public JEditorPane pane;
    static public String getContents(File aFile) {
    StringBuffer contents = new StringBuffer();
    try {
    BufferedReader input = new BufferedReader(new FileReader(aFile));
    try {
    String line = null;
    while (( line = input.readLine()) != null){
    contents.append(line);
    contents.append(System.getProperty("line.separator"));
    finally {
    input.close();
    catch (IOException ex){
    ex.printStackTrace();
    return contents.toString();
    public SampleProgram() {
    pane = new JEditorPane();
    pane.setContentType("text/html");
    pane.setEditable(false);
    pane.setCaretPosition(0);
    pane.setAutoscrolls(true);
    getContentPane().add(pane, BorderLayout.CENTER);
    setSize(400,400);
    File file = new File("D:/Audit_Log.html");
    String summary = getContents(file);
    System.out.println("Memory used Before setText invoke ==>" +((Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory())/1000000)+"M");
    pane.setText(summary);
    System.out.println("Memory used after setText invoke ==>" +((Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory())/1000000)+"M");
    setVisible(true);
    * @param args
    public static void main(String[] args) {
    new SampleProgram () ;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The html i am trying to display is similar to the one below.But the original content almost 10 times bigger than this html content and it has only td and tr tags. and for this file the leak is about 4 MB and if I use the file 10 times bigger than this it is 40M .
    Any suggestions how to avoid this memory leak?
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    <html>
    <body>
    <h1 align="center">Test HTML</h1>
    <table align="center" border="0" width="90%">
    <tr>
    <td>
    <h3>10-Sep-2008 08:11:32 GMT - <i>User</i>
    </h3>
    <h4>Employee 1 - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 2 - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 3, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 4, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 5, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 6, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 7, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 8, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 9, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 10, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 11, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 12, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 13, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 14, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 15, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 16, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 17, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 18, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 19, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 20, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 21, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 22, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 23, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 24, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 25, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 26, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 27, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 28, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 29, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 30, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 31, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 32, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 33, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 34, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 35, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 36, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>Green</td>
    </tr>
    <tr>
    <td>vision</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 37, - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Name</td><td></td><td>xyzxyz</td>
    </tr>
    <tr>
    <td>Place</td><td></td><td>Mangalore</td>
    </tr>
    <tr>
    <td>State</td><td></td><td>Karnataka</td>
    </tr>
    <tr>
    <td>Country</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    <tr></tr>
    <tr>
    <td>Unit </td><td></td><td>India/MT</td>
    </tr>
    <tr>
    <td>Floor</td><td></td><td>MARblE</td>
    </tr>
    <tr>
    <td>Rating</td><td></td><td>Quantity: amount = 45 uom = MT</td>
    </tr>
    </table>
    <br>
    <h4>Employee 60, Employed - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Price</td><td></td><td>India/MT</td>
    </tr>
    </table>
    <br>
    <h4>Employee 61, Employee - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Accept the agreement</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Indicator</td><td></td><td>True</td>
    </tr>
    <tr>
    <td>Conditions</td><td></td><td>AIR</td>
    </tr>
    <tr>
    <td> Status</td><td></td><td>QUALIFIED</td>
    </tr>
    <tr>
    <td>Job Type</td><td></td><td>ddddd</td>
    </tr>
    <tr>
    <td>agreement signed</td><td></td><td>TRUE</td>
    </tr>
    <tr>
    <td>Degree</td><td></td><td>True</td>
    </tr>
    <tr>
    <td> Options</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Quality</td><td></td><td>TRUE</td>
    </tr>
    <tr>
    <td>Quantity</td><td></td><td>123</td>
    </tr>
    <tr>
    <td>Basis</td><td></td><td>TOTAL</td>
    </tr>
    <tr>
    <td>GapPresent</td><td></td><td>TRUE</td>
    </tr>
    <tr>
    <td>Unit </td><td></td><td>MT</td>
    </tr>
    <tr>
    <td>Warning</td><td></td><td>4000000</td>
    </tr>
    <tr>
    <td>Rounding </td><td></td><td>3</td>
    </tr>
    <tr>
    <td>Security</td><td></td><td>OC</td>
    </tr>
    <tr>
    <td>Number</td><td></td><td>61</td>
    </tr>
    <tr>
    <td>Employee Status</td><td></td><td>Rupee INDIA</td>
    </tr>
    </table>
    <br>
    <h4>Employee 61 - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Alternative </td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Advantage</td><td></td><td>all</td>
    </tr>
    <tr>
    <td>Loading</td><td></td><td>all</td>
    </tr>
    <tr>
    <td>flag</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Lateral</td><td></td><td>True</td>
    </tr>
    <tr>
    <td> Mode</td><td></td><td>Null</td>
    </tr>
    </table>
    <br>
    <h4>Employee 61, Chain - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Roll Number</td><td></td><td>1</td>
    </tr>
    <tr>
    <td>Section</td><td></td><td>AA</td>
    </tr>
    <tr>
    <td>Percentage</td><td></td><td>100</td>
    </tr>
    </table>
    <br>
    <h4>Employee 61, Employee Terms - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Date of Record</td><td></td><td>DateRange
    startDate=01-Jun-2009
    endDate=30-Jun-2009
    </td>
    </tr>
    <tr>
    <td>Continent</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 61, Employed - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Price</td><td></td><td>India/MT</td>
    </tr>
    </table>
    <br>
    <h4>Employee 61, Employed Term 1, Fixed Employed - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Alternative</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Price </td><td></td><td>123</td>
    </tr>
    <tr>
    <td>Unit </td><td></td><td>India/MT</td>
    </tr>
    <tr>
    <td>Floor</td><td></td><td>MARblE</td>
    </tr>
    <tr>
    <td>Remainder</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Rating</td><td></td><td>Return: amount = 55 uom = HH</td>
    </tr>
    </table>
    <br>
    <h4>Employee 61, Employed Term 2, Fixed Employed - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Price </td><td></td><td>123</td>
    </tr>
    <tr>
    <td>Unit </td><td></td><td>India/MT</td>
    </tr>
    <tr>
    <td>Floor</td><td></td><td>MARblE</td>
    </tr>
    <tr>
    <td>Rating</td><td></td><td>Quantity: amount = 45 uom = MT</td>
    </tr>
    </table>
    <br>
    <h4>Employee 61, Demurrage - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Country</td><td></td><td>Africa</td>
    </tr>
    <tr>
    <td>Term Period</td><td></td><td>2 months</td>
    </tr>
    <tr>
    <td>Time Period</td><td></td><td>Asia</td>
    </tr>
    <tr>
    <td>Flag ON/OFF</td><td></td><td>Asia</td>
    </tr>
    </table>
    <br>
    <h4>Employee 61, Organisation Job Settlement Term - <i>Create</i>
    </h4>
    <table border="0" width="100%">
    <th align="left" width="40%"><u>Field Name</u></th><th align="left" width="30%"><u>From Value</u></th><th align="left" width="30%"><u>To Value</u></th>
    <tr>
    <td>Indicator</td><td></td><td>aaaaa</td>
    </tr>
    <tr>
    <td>Alt Event</td><td></td><td>blSPLIT</td>
    </tr>
    <tr>
    <td>Alt Osssssssssssssst</td><td></td><td>2</td>
    </tr>
    <tr>
    <td>Calendar</td><td></td><td>NEW YORK</td>
    </tr>
    <tr>
    <td>Currency Type</td><td></td><td>India</td>
    </tr>
    <tr>
    <td>Day</td><td></td><td>aaaaa</td>
    </tr>
    <tr>
    <td>Event</td><td></td><td>bl</td>
    </tr>
    <tr>
    <td>alter ddddddddd</td><td></td><td>Asia</td>
    </t

    Screen_Name_09, You can post in the bug database.
    http://bugs.sun.com/bugdatabase/

  • JEditorPane - HTML Problem

    Hello people:
    I am new to your forum and have this problem: I am using a JEditorPane component in my GUI and wish to fornat it using text/html. This I have done. I also want to dynamically add content to it from functions in my program, but this is not possible as, when the first content is added to the Pane, it is terminated with a </html> tag. Is there a way that I can specify it not to do this so that I can dynamically add my HTML content throught the life of my program.
    Regards and thanks in advance,
    mintsmike

    camickr wrote:
    Cross postedThanks for the heads-up.
    db

  • SetText Problem...

    Hello all! Well i'm trying to make a simple Set comparison applet. My problem is when i try and compile my script it gives me this error....
    C:\.....\SetApplet.java:212: cannot resolve symbol
    symbol : method setText (boolean)
    location: class java.awt.TextField
              answerField.setText(set1.equals(set2));
    So here is my code for the SetApllet....
    import java.io.*;
    import java.applet.Applet;
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.util.Enumeration;
    import java.util.Vector;
    import java.lang.*;
    public class SetApplet extends Applet implements ActionListener, ItemListener {
    private Set set1;
    private Set set2;
    private Set resultSet;
    private Set activeSet; // reference to the currently selected Set (set1 or set2)
    private Checkbox set1Selector;
    private Checkbox set2Selector;
    private CheckboxGroup selectorGroup;
    private List set1List; // list showing elements of set1
    private List set2List; // list showing elements of set2
    private List resultList; // list showing the elements of a result (of union or intersect) Set
    private List activeList; // reference to the currently selected List (set1List or set2List)
    private Button addButton;
    private TextField value, answerField;
    private Button intersectButton, complementButton, unionButton, clearButton, equalsButton;
         private Color background, blue, yellow;
         private Panel row0, row1, row2, row3, row4, row5, row6;
         private     Label headerLabel, label1, label2, label3, label4, label5, label6;
         private String subset1, subset2, subsetadd;
    public SetApplet() {
         * makePanel is a method that sets the layout and background color of each panel it is called to create.
         * @param lm Set's Layout
         * @param c Set's Background Color of Panel
         * @return returns new button
         private Panel makePanel(LayoutManager lm, Color c) {
              Panel p = new Panel();
              p.setLayout(lm);
              p.setBackground(c);
              return p;
         * makeButton is a method that sets the label and color of each new button that is created.
         * @param label string label to be used on the new button
         * @param color color of the new button
         * @return returns new button
         private Button makeButton(String label, Color color) {
              Button x = new Button(label);
              x.setBackground(color);
              x.setFont(new Font("Verdana", Font.BOLD, 14));
              return x;
    * Initialize the Applet
    public void init() {
         //--- create Model
         set1 = new Set();
         set2 = new Set();
         //--- create GUI
         background = new Color(54,140,203);
                        //blue = new Color(129,129,218);
                        blue = new Color(54,140,203);
                        yellow = new Color(255,255,102);
         this.setLayout(new FlowLayout(FlowLayout.CENTER,4,1));
         // Checkboxes
         headerLabel = new Label("Choose the set you want to add or clear: ");
         set1Selector = new Checkbox("Set 1");
         set2Selector = new Checkbox("Set 2");
         row0 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),background);
         row0.add(headerLabel);
         row0.add(set1Selector);
         row0.add(set2Selector);
         // Lists
         row1 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),background);
         set1List = new List();
         set2List = new List();
         resultList = new List();
         row1.add(new Label("Set 1"));
         row1.add(set1List);
         row1.add(new Label("Set 2"));
         row1.add(set2List);
         row1.add(new Label("Result"));
         row1.add(resultList);
         row2 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),background);
         addButton = new Button("Add:");
         value = new TextField(5);
         clearButton = new Button("Clear");
         label1 = new Label("Enter an Integer in the text field and press [Add] to add to indicated set: ");
         row2.add(label1);
         row2.add(addButton);
         row2.add(value);
         row3 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),background);
         label2 = new Label("Press this button to clear sets: ");
         row3.add(label2);
         row3.add(clearButton);
         // Buttons
         row4 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),background);
         label3 = new Label("Set 1");
         label4 = new Label(" Set 2");
         unionButton = new Button("Union");
         intersectButton = new Button("Intersect");
         complementButton = new Button("Complement");
         row4.add(label3);
         row4.add(unionButton);
         row4.add(intersectButton);
         row4.add(complementButton);
         row4.add(label4);
         //tests
         row5 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),background);
         label5 = new Label("Test");
         equalsButton = new Button("Equals");
         answerField = new TextField(5);
         row5.add(label5);
         row5.add(equalsButton);
         row5.add(answerField);
         //--- group Checkboxes
         selectorGroup = new CheckboxGroup();
         set1Selector.setCheckboxGroup(selectorGroup);
         set2Selector.setCheckboxGroup(selectorGroup);
         //--- initialize GUI
         selectorGroup.setSelectedCheckbox(set1Selector);
         setActive();
         //--- register Listeners
         set1Selector.addItemListener(this);
         set2Selector.addItemListener(this);
         addButton.addActionListener(this);
         clearButton.addActionListener(this);
         unionButton.addActionListener(this);
         intersectButton.addActionListener(this);
         complementButton.addActionListener(this);
         equalsButton.addActionListener(this);
    add(row0);
    add(row1);
    add(row2);
    add(row3);
    add(row4);
    add(row5);
    public void paint(Graphics g) {
                   setSize(row1.getSize().width,200);
                   validate();
    //--- implement ActionListener
    * This method is called when one of the Buttons is pushed
    public void actionPerformed(ActionEvent ev) {
         Object eventSource = ev.getSource();
         if (eventSource==addButton) {
         // add
         int i = Integer.parseInt(value.getText());
         activeSet.addElement(new Integer(i));
         updateList(activeList, activeSet);
         } else if (eventSource==clearButton) {
         // clear
         activeSet.removeAllElements();
         updateList(activeList, activeSet);
         } else if (eventSource==unionButton) {
         // union
         resultSet = set1.union(set2);
         updateList(resultList, resultSet);
         } else if (eventSource==intersectButton) {
         // intersect
         resultSet = set1.intersection(set2);
         updateList(resultList, resultSet);
         } else if (eventSource==complementButton) {
              // complement
              resultSet = set1.complementWithRespectTo(set2);
              updateList(resultList, resultSet);
         } else if (eventSource==equalsButton) {
              // equals
              answerField.setText(set1.equals(set2));
    //--- implement ItemListener
    * This method is called, when one of the Checkboxes is selected
    public void itemStateChanged(ItemEvent ev) {
         setActive();
    //--- private worker methods
    * Set activeList and activeSet depending on the selected Checkbox
    private void setActive() {
         List newActiveList;
         if (selectorGroup.getSelectedCheckbox()==set1Selector) {
         activeList = set1List;
         activeSet = set1;
         } else {
         activeList = set2List;
         activeSet = set2;
    * Set the contents of the List according to the contents of the Set
    private void updateList(List list, Set set) {
         if (list.getItemCount() != 0) {
         list.removeAll();
         //--- enumerate loop pattern
         Enumeration en = set.elements();
         while (en.hasMoreElements()) {
         // get next
         Integer i = (Integer)en.nextElement();
         // process
         list.add(i.toString());
    Here is my code for my set.java, the equals method is at the bottom.....
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    class Set {
         public Set() {
              vector = new Vector();
         public boolean isEmpty() {
              return vector.isEmpty();
         public int size() {
              return vector.size();
         public boolean contains(Object o) {
              Enumeration enum = vector.elements();
              while (enum.hasMoreElements()) {
                   Object elem = enum.nextElement();
                   if (elem.equals(o))
                        return true;
              return false;
         public void addElement(Object o) {
              if (!contains(o))
                   vector.addElement(o);
         public Object copy() {
              Set destSet = new Set();
              Enumeration enum = vector.elements();
              while (enum.hasMoreElements())
                   destSet.addElement(enum.nextElement());
              return destSet;
         public Set union(Set s) {
              Set unionSet = (Set)s.copy();
              Enumeration enum = vector.elements();
              while (enum.hasMoreElements())
                   unionSet.addElement(enum.nextElement());
              return unionSet;
         public Set intersection(Set s) {
              Set interSet = new Set();
              Enumeration enum = this.vector.elements();
              while (enum.hasMoreElements()) {
                   Object elem = enum.nextElement();
                   if (s.contains(elem))
                        interSet.addElement(elem);
              return interSet;
         void removeAllElements() {
         vector.removeAllElements();
         Enumeration elements() {
         return vector.elements();
         public void print(PrintStream ps) {
              Enumeration enum = vector.elements();
              while (enum.hasMoreElements()) {
                   ps.print(enum.nextElement().toString());
                   ps.print(" ");
         //newstuff
         public Set complementWithRespectTo(Set s) {
         // Returns a set containing all elements in s not in the receiver object
         Set complement = new Set();
              Enumeration enum = this.vector.elements();
              while (enum.hasMoreElements()) {
                   Object elem = enum.nextElement();
                   if (!s.contains(elem))
                   complement.addElement(elem);
              return complement;
         public boolean equals(Object right){
         // Returns true if each of the receiver object and s is a subset of
         // the other, and false otherwise
              Enumeration enum = vector.elements();
              while (enum.hasMoreElements()) {
                   Object elem = enum.nextElement();
                   if (elem.equals(right))
                        return true;
              return false;
    Vector vector;
    Any thoughts? THANKS ALOT!
    I LOVE THIS FORUM!
    Paul

    Hi
    The argument from method setText must to be a string!
    One solution:
    answerField.setText( (set1.equals(set2) ? "TRUE" : "FALSE") );
    Next time post a snippet and explain error not the full source code since most people hate to read long posts and reject the answer.
    Regards.

  • JEditorPane setpage() problems

    Hi all!!
    I am developing a SWING application wich consists of a JFrame that contains a splitpane with a JTree on the left side and a JPanel with a cardlayout on the right one.
    Once the user navigates through the tree on the left different cards get loaded on the right panel.
    My problem is that when I show the card where a JEditorPane is located and use the setPage(url) to modify the document to be shown nothing happens, meaning that it doesn�t change the document that is displayed (the one URL that I passed on creating the JEditorPane). I mean, the card gets loaded, and I have confirmed that the URL that I pass exists and I pass different ones as well, but nothing seems to happen and the document remains the same.
    Please, can you give me any hints of why this is happening? Can I repaint the card or something??
    Is there any relationship between the CardLayout and the unability to setPage the JEditorPane.
    Please Help!!
    Here is the code:

    I've had this Problem when I was building a HTML-Editor-Applet.
    The Problem was, that there was a Style-Attribute like e.g. text-decoration:underlined. If I removed the underlined style the Attribut was text-decoration:none, but the getText() method just cared about the Style with the name text-decoration to handle this Element as underlined. I had to build my own getText() method by examing all the Elemntes from the Document and set the html-Tags for the style-attributes.
    J&ouml;rn

  • JEditorPane Initialization problem

    Hi All,
    I am getting the following error if i am trying to initialize JEditorPane as below,
    JEditorPane j_msgPanel=new JEditorPane("file:\\\\C:\\msgCreator\\blank.html");
    java.net.ConnectException: Operation timed out: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.NetworkClient.openServer(Unknown Source)
    at sun.net.ftp.FtpClient.openServer(Unknown Source)
    at sun.net.ftp.FtpClient.<init>(Unknown Source)
    at sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Sour
    ce)
    at javax.swing.JEditorPane.getStream(Unknown Source)
    at javax.swing.JEditorPane.setPage(Unknown Source)
    at javax.swing.JEditorPane.<init>(Unknown Source)
    at adx.msg.TabbedMsgCreator.jbInit(TabbedMsgCreator.java:104)
    at adx.msg.TabbedMsgCreator.<init>(TabbedMsgCreator.java:89)
    at adx.msg.Login.submitClicked(Login.java:167)
    at adx.msg.Login.access$000(Login.java:18)
    at adx.msg.Login$2.actionPerformed(Login.java:77)
    at javax.swing.JTextField.fireActionPerformed(Unknown Source)
    at javax.swing.JTextField.postActionEvent(Unknown Source)
    at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source)
    at javax.swing.SwingUtilities.notifyAction(Unknown Source)
    at javax.swing.JComponent.processKeyBinding(Unknown Source)
    at javax.swing.JComponent.processKeyBindings(Unknown Source)
    at javax.swing.JComponent.processKeyEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processKeyEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    For more information, i am using
    java version "1.3.1"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
    Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
    I have no idea why it is going for ftp connection :( when the file referenced is a local file.
    Thanks in Advance.

    Sorry i forgot to add that this works fine with jdk 1.4.1 version

  • Need help.. displaying images with setText on a JEditorPane

    Does anybody know how to embed an image into html text when using the JEditorPane.setText?
    The images are stored in a jar file, and we know how to retrieve them and store them in an Image object from getDefaultToolkit().getImage()
    Sample codes would be really nice, but any answers will be greatly appreciated. Thanks!

    The following is from some code I worked on a while ago, seemed to work fine however this was only a test tool so I didnt test it fully!
    public static final java.net.URL ERROR_ICON = ClassLoader.getSystemResource ("xmlviewer/res/error.gif");
    // some code....
    public void reportError (String msg) {
            String err = "<img src=" + ERROR_ICON.toString() + "> " +
                         makeHTMLFriendlyString(msg) + "<br>";
            reportList.append (err);
            jTextAreaParseErrors.setText (  reportList.toString() );
    }Obviously you will have to put your own image path into the .getSystemResource call. Hope this helps!
    Jon

  • Performance of JEditorPane with unicode characters

    Hi,
    I'm using a JEditorPane to edit rather large (> 15000 words) but simple HTML files. Everyting is fine until I add even a single unicode character to the text with a character code higher than 255, like a Greek omega (\u03A9). With the unicode character the control starts to take an incredibly long time to redraw (sometimes minutes) when you resize it, for instance. The strangest thing is that removing the character again does not restore performance. Can anyone explain why this is happening?
    import javax.swing.*;
    import javax.swing.text.html.HTMLEditorKit;
    public class EditorPaneTest {
    public static void main(String[] args) {
    StringBuffer html = new StringBuffer();
    html.append("<html><body>");
    // Uncomment next line, run and resize frame to see problem
    // html.append("<p>\u03A9</p>");
    for (int i = 0; i < 2000; i++) {
    html.append("<p>Testing, testing, testing...</p>");
    html.append("</body></html>");
    JFrame jFrame = new JFrame("Test");
    jFrame.setSize(300, 300);
    JEditorPane jEditorPane = new JEditorPane();
    jEditorPane.setEditorKit(new HTMLEditorKit());
    jFrame.add(new JScrollPane(jEditorPane));
    jFrame.setDefaultCloseOperation(JInternalFrame.EXIT_ON_CLOSE);
    jFrame.setVisible(true);
    jEditorPane.setText(html.toString());
    }Any help would be much appreciated.
    Thanks,
    Rasmus

    In the meantime, I had to solve my problem one way or another, and the only thing that came up to my mind was to use JavaMail API.
    It is not quite what I was hoping for, because it doesn't provide opening of default e-mail client on local machine, but at least it can send e-mail with Unicode characters in the subjects line, recipient addresses, etc.
    Make a new message using JavaMail and then set it's properties in a fairly simple manner, like this:
    message.setSubject( MimeUtility.encodeText("+ ... some Unicode text with Cyrillic symbols ... +", "UTF-8", "B") );I'd still like to see if there are any suggestions on how to do the similar thing with java.awt.Desktop.
    Regards,
    PS

  • Named Anchor in JEditorPane HTML

    I am loading an HTML string into a JEditorPane.
    The string has some named anchors (<A NAME="blah">) that reference other locations in the HTML string.
    Because I am loading the HTML string by using JEditorPane.setText, the named anchors do not work. This seems to be a problem when my HyperLinkListener tries to find the target URL.
    Does anyone know how to solve this problem?

    Did you find a solution for this problem in the meantime? I'd like to implement an online help feature in my newest program. I wrote a HTML text with anchors/links and the program loads this text to an JEditorPAne witch HTMLEditorKit by using the EditorPanes 'read' method. But all I got are HyperLinkExceptions from the HyperlinEventListener.
    regards, hgw2

  • JEditorPane - mouse click simulation doesn't work

    Hi all,
    I have a little problem with my JEditorPane. I want to implement the posibility to put signs on a document loaded in a jeditorpane and save them. One solution is to save the position of the scrollbar, but because the font size can be changed it will not be working. So I want to simulate a cmouse click on the first row of text from viewport to put there the caret and take after that his position. The problem is that the simulation for the mouse click donesn,t work. The event is simulated, but the caret position is not changing.
    I tried also using Robot class, but this implementation give me a serie a mouse events and it moves the cursor to the requested position and it's not the behaviour that I want.
    Here is my code:import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.JButton;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.text.BadLocationException;
    public class Reader {
         JEditorPane jEditorPane;
         JScrollPane editorScrollPane;
         private JFrame frame;
         private JPanel readerPane;
         private JPanel commandsPane;
          * @param args
         public static void main(String[] args) {
              new Reader();
         public Reader() {
              frame = new JFrame();
              createReader();
              createCommands();
              addPanes();
              frame.setSize(1000, 850);
              // frame.setExtendedState(frame.MAXIMIZED_BOTH);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              loadHtml();
         private void addPanes() {
              GridBagLayout layout = new GridBagLayout();
              frame.setLayout(layout);
              GridBagConstraints c = new GridBagConstraints();
              c.fill = GridBagConstraints.BOTH;
              c.gridx = 1;
              c.gridy = 0;
              c.ipadx = 0;
              c.ipady = 0;
              c.weightx = 1;
              c.weighty = 2;
              frame.add(readerPane, c);
              c = new GridBagConstraints();
              c.fill = GridBagConstraints.HORIZONTAL;
              c.gridx = 1;
              c.gridy = 1;
              c.ipadx = 0;
              c.ipady = 10;
              c.weightx = 0;
              c.weighty = 0;
              c.gridwidth = 1;
              c.gridheight = 1;
              frame.add(commandsPane, c);
         private void createCommands() {
              commandsPane = new JPanel();
              commandsPane.setBackground(Color.white);
              JButton backButton = new JButton("PUSH");
              commandsPane.add(backButton);
              backButton.addMouseListener(new MouseListener() {
                   @Override
                   public void mouseClicked(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mouseEntered(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mouseExited(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mousePressed(MouseEvent e) {
                        MouseEvent click = new MouseEvent(jEditorPane,
                                  MouseEvent.MOUSE_CLICKED, System.currentTimeMillis(),
                                  16, 10, 200, 1, false, 1);
                        MouseListener[] listeners = jEditorPane.getMouseListeners();
                        for (int i = 0; i < listeners.length; i++) {
                             listeners.mouseClicked(click);
                   @Override
                   public void mouseReleased(MouseEvent e) {
                        // TODO Auto-generated method stub
         private void createReader() {
              jEditorPane = new JEditorPane();
              jEditorPane.setEditable(false);
              jEditorPane.setSelectionColor(Color.green);
              jEditorPane.addMouseListener(new MouseListener(){
                   @Override
                   public void mouseClicked(MouseEvent e) {
                        System.out.println("clicked");
                        System.out.println("caret pos = "
                                  + jEditorPane.getCaretPosition());
                   @Override
                   public void mouseEntered(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mouseExited(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mousePressed(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mouseReleased(MouseEvent e) {
                        // TODO Auto-generated method stub
              editorScrollPane = new JScrollPane(jEditorPane);
              editorScrollPane.setBorder(null);
              editorScrollPane.getVerticalScrollBar().setPreferredSize(
                        new Dimension(0, 0));
              readerPane = new JPanel();
              readerPane.setBackground(Color.black);
              readerPane.setLayout(new GridBagLayout());
              JPanel spacePane = new JPanel();
              spacePane.setBackground(Color.white);
              GridBagConstraints c = new GridBagConstraints();
              c = new GridBagConstraints();
              c.fill = GridBagConstraints.NONE;
              c.ipadx = 500;
              c.ipady = 650;
              c.weighty = 1;
              c.weightx = 1;
              c.gridx = 1;
              c.gridy = 1;
              c.gridwidth = 1;
              c.gridheight = 1;
              readerPane.add(spacePane, c);
              spacePane.setLayout(new GridBagLayout());
              c = new GridBagConstraints();
              c.fill = GridBagConstraints.BOTH;
              c.weighty = 1;
              c.weightx = 1;
              c.gridx = 0;
              c.gridy = 0;
              c.gridwidth = 1;
              c.gridheight = 1;
              c.insets = new Insets(20, 20, 20, 20);
              spacePane.add(editorScrollPane, c);
         private void loadHtml() {
              System.out.println("load html file");
              jEditorPane.setContentType("text/html");
              jEditorPane.setText("<html><body>" +
                        "<p>some text here for testing some text here for testing some text here for testing some text here for testing " +
                        "some text here for testing some text here for testing some text here for testing some text here for testing " +
                        "some text here for testing some text here for testing some text here for testing some text here for testing " +
                        "some text here for testing some text here for testing some text here for testing some text here for testing " +
                        "some text here for testing some text here for testing some text here for testing some text here for testing </p>" +
                        "</body></html>");
              jEditorPane.revalidate();
    If tou run this code you can observe that when the "PUSH" button is pressed the jeditorpane receives a mouseclick event, but the caret position is not changing.
    Strange is that when you click with the mouse over the editor pane the caret position is changed and I don't understand what is wrong.
    Can you help me please?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You can use viewToModel() method to get caret position for x, y location. No need to click.
    Regards,
    Stas

  • Thread-safety problems

    I assume calling setText() for a JLabel and JButton is not thread safe by default. What if I only do this from one single thread other than the event-dispatching thread?
    Please help me clarify this.

    I was going to start my own thread, but this one looks just perfect.
    First of all, according to the API for JTextComponent (and JEditorPane), the method setText() IS ALREADY THREAD SAFE.
    "This method is thread safe, although most Swing methods are not."
    So you should always be able to call setText() on a text component without sticking it in an invokeLater() block.
    Now that I've said that, I seem to have encountered proof that setText() is NOT thread safe... observe the following stack trace:
    java.lang.ArrayIndexOutOfBoundsException
            at java.lang.System.arraycopy(Native Method)
            at javax.swing.text.BoxView.updateLayoutArray(Unknown Source)
            at javax.swing.text.BoxView.replace(Unknown Source)
            at javax.swing.text.View.updateChildren(Unknown Source)
            at javax.swing.text.View.changedUpdate(Unknown Source)
            at javax.swing.text.html.BlockView.changedUpdate(Unknown Source)
            at javax.swing.plaf.basic.BasicTextUI$RootView.changedUpdate(Unknown Source)
            at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.changedUpdate(Unknown Source)
            at javax.swing.text.AbstractDocument.fireChangedUpdate(Unknown Source)
            at javax.swing.text.html.HTMLDocument.fireChangedUpdate(Unknown Source)
            at javax.swing.text.html.HTMLDocument$HTMLReader.adjustEndElement(Unknown Source)
            at javax.swing.text.html.HTMLDocument$HTMLReader.flush(Unknown Source)
            at javax.swing.text.html.HTMLEditorKit.read(Unknown Source)
            at javax.swing.JEditorPane.setText(Unknown Source)
    // remaining stack trace from my program, omittedThat's a swing-thread bug if I ever saw one (and I've seen THOUSANDS)
    Moving right along... my specific problem is that I am calling setText() on a JTextPane. Here's the weird part: If I call setText() normally, all is good. If I call setText() from inside a invokeLater() block (to avoid the above extremely rare exception), it fills the JTextPane, --BUT-- it is then scrolling the JTextPane to the bottom! (Normally, it just leaves it at the top, which is where I want it to be)
    Does anybody know if this is normal behaviour or erratic? Should I just add a workaround to set the scroll back to the top, or is there a deeper problem I should be looking for?

  • I can't add simple HTML link to HTMLDocument in jEditorPane

    h5. How to construct a link to make it work?
    HTMLDocument doc = (HTMLDocument) jEditorPane.getDocument();
    String link = dialogSlownikEkranow.getLink();
    SimpleAttributeSet tag = new SimpleAttributeSet();
    SimpleAttributeSet attrs = new SimpleAttributeSet();
    tag.addAttribute(HTML.Tag.A, attrs);
    attrs.addAttribute(HTML.Attribute.HREF, link);
    +try {+
    + doc.insertString(jEditorPane.getCaretPosition(), "some link", tag);+
    +} catch (BadLocationException e1) {+
    + e1.printStackTrace();+
    +}+
    h5. As a result I get
    <+a href="\mw\client\cd\plytacd.html"><p></a>+
    h5. but I require something like
    <+a href="\mw\client\cd\plytacd.html">some link</a>+

    Hi,
    nirgal wrote:
    h5. How to construct a link to make it work?
    HTMLDocument doc = (HTMLDocument) jEditorPane.getDocument();
    SimpleAttributeSet tag = new SimpleAttributeSet();
    SimpleAttributeSet attrs = new SimpleAttributeSet();
    tag.addAttribute(HTML.Tag.A, attrs);
    attrs.addAttribute(HTML.Attribute.HREF, link);
    I don't believe that SimpleAttributeSet is right for HTMLDocument. In your code, you regard a HTML.Tag as a AttributeSet. Apparently this is not the absolute truth. May be I'm wrong, then one may correct me.
    My suggest�on is to use string concatenation to make the HTML for the link and then use HTMLEditorKit.read to put this HTML into the HTMLDocument on caret position.
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    import javax.swing.text.*;
    public class JEditorPaneSample {
      private static void createAndShowGUI() {
        JFrame frame = new JFrame("FrameDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JEditorPane jeditorpane = new JEditorPane();
        jeditorpane.setContentType("text/html");
        jeditorpane.setText("<p>Hello World</p>");
    //insert a link on caret position
    String link = "mw/client/cd/plytacd.html";
    String htmlstring = "<a href=\"";
    htmlstring += link + "\">";
    htmlstring += "some link" + "</a>";
    try {
      jeditorpane.getEditorKit().read(new StringReader(htmlstring), jeditorpane.getDocument(), jeditorpane.getCaretPosition());
    } catch (BadLocationException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
        System.out.println(jeditorpane.getText());
        frame.getContentPane().add(jeditorpane, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
      public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            createAndShowGUI();
    }greetings
    Axel

  • Display HTML in JEditorPane

    Hi
    I am trying to display a String containing HTML text on a JEditorPane.
    I have downloaded the HTML from a webpage using sockets, and now I want to display the downloaded page. I have a project in school about sockets.
    This is why I can't use getPage(URL);
    The following is the code I am using:
    String temp = "String with HTML text"
    HTMLEditorKit htmlEdKit = new HTMLEditorKit();
    JEditorPane.setEditorKit(htmlEdKit);
    JEditorPane.setContentType("text/html");
    JEditorPane.setEditorKitForContentType("text/html", htmlEdKit);
    JEditorPane.setContentType("text");
    JEditorPane.setText(temp);
    When I run the code, all that is displaying is the raw HTML code, with all the tags. As I understand it, this is how it should be done.
    What is wrong, would appreciate some help.
    /David Mossberg

    it's not necessary to use socket but if use socket get the inputstream from it.
    in = socket.getinputstream(); //return inputstream from socket
    htmldoc = JEditorPane.getDocument(); //return the htmldoc in JEditorPane
    if(htmldoc.getlength()>0)
    htmldoc.remove(0,htmlDoc.getLength());//if the htmldoc has some content then remove it
    reader = new InputStreamReader(in);//construct a new reader from in
    JEditorPane.getEditorKit.read(reader,htmldoc,0); //read new content into the htmldoc from reader
    Hope the above code helps you.
    joney

Maybe you are looking for

  • HELP..I received the message..."403 Forbidden" on the OSX Lion download.

    Help... I downloaded the Mac OSX x10.6.8 Snow Leapard update. Then I downloaded the OSX Lion, but with in two seconds I received a message "403 Forbidden".  What am I doing wrong?

  • Help! I can only print letter size

    I have Photoshop Elements 7, Windows XP, and an HP Photosmart 8250 printer.  When I try to print from the Editor my picture gets truncated to letter size.  My default printer setting is A4.  I can select A4 in Page Setup and click OK.  But if I open

  • Finding out what Subtype a reference is

    Hi! I'm trying to bulid an applicaton with abab g and as a Java developer I'm doing it with Abap Objects. Now I have a nice abstract superclass and now I have to check references what type they have, before casting them into the subclasses. I'm looki

  • Can-not find VAFUX.DLL

    It is a problem with QuickTime 7. Tried deleting references in the registry, reloading with-out ITunes, Updating to the latest Direct-X. Still have the problem. QuickTime will bring up the message several times, then it seems to work okay. It also af

  • Unable to change DVD Region

    Hello  We've had a Lenovo G550 2958 laptop for about a year now and only recently tried to play a DVD on it. I had a message to say that it couldn't be played as it's a region 2 DVD (which it is) and this is a region 1 machine. The system then gives