• Post Reply Bookmark Topic Watch Topic
  • New Topic

still having problems with file IO  RSS feed

 
Randall Twede
Ranch Hand
Posts: 4683
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have problems with both the open and save methods. my question is about the open problem. the code opens .txt, .rtf, .html, .java, etc.
the problem is it opens html files like a browser does(displays the page).
this is a word processor program.
i need it to display the source so it can be edited
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API docs
The setPage method can be used to initialize the component from a URL. In this case, the content type will be determined from the URL, and the registered EditorKit for that content type will be set.

Try using setText instead. (Of course you will have to read the file as text before invoking this)
 
Randall Twede
Ranch Hand
Posts: 4683
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, that sounds like what i need. i am also thinking i could read it the way i am doing and have a menuItem(view html source) that reads the file again as text.
 
Randall Twede
Ranch Hand
Posts: 4683
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh was correct, i had to use setText() instead of setPage().
i also had to first change the EditorKit.
it seems to work just fine.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!