Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: writing to JEditorPane

  1. #1
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default writing to JEditorPane

    does any body know what is wrong with this code for writing to a jeditorpane?

     while(r>0 & r<l & e>0){
    		    	file = new File("result.html");
    				fos = new FileOutputStream(file);
    				dos = new DataOutputStream(fos);
    			   	dos.writeBytes(Results.substring(r, e));
    		    	java.net.URL Content =  file.toURI().toURL();
    		    	System.out.println(Results.substring(r, e));
    		       	tArea[i].setPage(Content);
    		    	r = Results.indexOf("<a href=",e);
    		    	e = Results.indexOf("Cached",r);
    		    	i++;
    		    	fos.close();
    			    dos.close();
    			    file.delete();
     
    		    }

    I am sure about the data of "file" that I am writing it to my JEditorpane, but what is displayed in "tArea" is not what it should be. this the only part of my program in which "tArea" is being used. it would be good even if somebody tell me how to test it to undrestand the reason.
    Last edited by nasi; April 8th, 2010 at 10:47 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,307
    Thanks
    181
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: writing to JEditorPane

    Try calling flush() on your DataOutputStream, and even close the dos prior to attempting to creating the URL to the file

  3. #3
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Re: writing to JEditorPane

    it didn't fix the problem. the content of file is correct but it isn't written to editorpane properly?

Similar Threads

  1. refreshing JEditorPane
    By nasi in forum AWT / Java Swing
    Replies: 9
    Last Post: April 9th, 2010, 04:01 AM
  2. writting to jeditorpane
    By nasi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 5th, 2010, 05:49 AM
  3. create buttons in a JEditorPane
    By seeker in forum AWT / Java Swing
    Replies: 4
    Last Post: December 5th, 2009, 08:01 AM
  4. Convert contents of JTextArea / JEditorPane to PDF
    By rangarajank in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: September 30th, 2009, 02:38 PM
  5. I need help writing this program
    By kev2000 in forum Algorithms & Recursion
    Replies: 5
    Last Post: June 4th, 2009, 03:14 AM

Tags for this Thread