LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 03-05-2002, 09:35 AM   #1
markdw
LQ Newbie
 
Registered: Nov 2001
Posts: 7

Rep: Reputation: 0
Question Java and saving an HTML file


I'm fairly new to Java and I'm hoping someone can help me out on this question. I'm opening up an html file in a JEditorPane. The html file has checkboxes. What I want to do is to be able to save the html file from my Java app. I know how to save the file, but I don't know how to save the file with the checkboxes checked. By default the first time you open the file the boxes will be unchecked, but if I have checked the box and then saved the file the next time I open this file I want those boxes to be checked. Does anybody have any suggestion? Hopefully this is clear. I am also willing to change the JEditorPane to something else if it would make it easier.

Thanks
 
Old 03-07-2002, 11:25 AM   #2
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 11.10
Posts: 423
Blog Entries: 1

Rep: Reputation: 36
I think that you may save this checkbox options in a db where the webpage can read,(it is just a suggestion),but I think it should work as you did.
 
Old 03-18-2002, 03:15 AM   #3
zmedico
Member
 
Registered: Feb 2002
Location: Mission Viejo, California, USA
Distribution: Gentoo
Posts: 707

Rep: Reputation: 30
The relevant area of the Java Tutorial is here:
http://java.sun.com/docs/books/tutor...ents/text.html

Something like this might help:

JEditorPane editorPane = new JEditorPane();
// Get a URL somehow
java.net.URL url = ClassLoader.getSystemClassLoader().getResource("readme.html");
editorPane.setPage(url);
HTMLDocument htmlDoc = (HTMLDocument) editorPane.getDocument();
htmlDoc.addDocumentListener(
new DocumentListener(){
public void changedUpdate(DocumentEvent e){
// handle DocumentEvent's
}
public void insertUpdate(DocumentEvent e){
// handle DocumentEvent's
}
public void removeUpdate(DocumentEvent e){
// handle DocumentEvent's
}
};
);

Pseudocode, with links:

call the getDocument() method on your JEditorPane:
http://java.sun.com/j2se/1.4/docs/ap...ditorPane.html

That will give you one of these:
http://java.sun.com/j2se/1.4/docs/ap.../Document.html

But you can cast it to one of these:
http://java.sun.com/j2se/1.4/docs/ap...LDocument.html

Then you can use the addDocumentListener method of HTMLDocument to listen for these:

http://java.sun.com/j2se/1.4/docs/ap...mentEvent.html

using a class you have created that implements this:

http://java.sun.com/j2se/1.4/docs/ap...tListener.html




Last edited by zmedico; 03-18-2002 at 03:28 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving a text file as a variable and reading it every second in java script mrobertson Programming 4 03-26-2007 08:25 PM
saving html from windows editor looses permissions aryehb Linux - Newbie 4 03-24-2005 02:20 PM
saving html pages with images in Konqueror nykysle Linux - General 1 12-19-2004 08:20 AM
Saving partial spreadsheet data as html wyld Linux - Software 1 09-21-2003 09:13 AM
saving html text to floppy jamaso Linux - General 4 03-18-2002 09:25 AM


All times are GMT -5. The time now is 04:41 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration