Results 1 to 16 of 16
Thread: Document variable
- 03-27-2011, 09:44 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 25
- Rep Power
- 0
Document variable
Just a quick and probably silly question, how do I set a document variable? I imagine it's is something like :
but that doesn't seem to work...Java Code:Document myDoc = new Document("C:/folder/file");
(I get an error saying javax.swing.text.Document is abstract, can not be instantiated)
cheers!Last edited by captain alge; 03-27-2011 at 10:04 AM.
- 03-27-2011, 09:50 AM #2
Senior Member
- Join Date
- Nov 2010
- Posts
- 210
- Rep Power
- 3
Would File work?
Plus, remember that "/" is the escape character. For a literal forward slash, use "//".
- 03-27-2011, 09:52 AM #3
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Document is abstract as the error suggests. Go to the document API and find a concrete implementation( I think DefaultStyledDocument) is one type.
- 03-27-2011, 09:56 AM #4
Member
- Join Date
- Mar 2011
- Posts
- 25
- Rep Power
- 0
No, apparently I need a document
- 03-27-2011, 09:58 AM #5
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Good luck instantiating an interface. If we are thinking of the same thing, a document is an interface. You can't create an instance of it, instead you create an instance of a class that implements the document interface. Google java 6 document.
- 03-27-2011, 10:03 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-27-2011, 10:09 AM #7
Without adequate background information, nobody is going to be able to answer that. What exactly are you aiming to do? (note, 'what', not 'how')how do I set a document variable?
db
- 03-27-2011, 10:45 AM #8
Member
- Join Date
- Mar 2011
- Posts
- 25
- Rep Power
- 0
forget it, I found an alternative way of doing what I wanted
- 03-27-2011, 10:49 AM #9
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Alright, what were you trying to do exacty? If you are done please mark your thread solved with the thread tools at the top.
- 03-27-2011, 11:20 AM #10
- 03-27-2011, 11:39 AM #11
Member
- Join Date
- Mar 2011
- Posts
- 25
- Rep Power
- 0
I was trying to set the content of a text area to be the contents of a file
used:
insteadJava Code:FileReader input = new FileReader(new File(locationoffile)); myTextArea.read(input, evt);
@Darryl.Burke not sure what your problem is
- 03-27-2011, 11:41 AM #12
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
You seemed like you came here, ignored advice and then just said nevermind.
You weren't actually looking for a document.
- 03-27-2011, 11:45 AM #13
Member
- Join Date
- Mar 2011
- Posts
- 25
- Rep Power
- 0
The advice wasn't particularly helpful, you think I hadn't already checked the API?
I didn't realise I didn't require a document, otherwise I wouldn't have posted
- 03-27-2011, 11:48 AM #14
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Your original question was overly vague and that's why we weren't able to provide you with a solid answer.
- 03-27-2011, 11:52 AM #15
Member
- Join Date
- Mar 2011
- Posts
- 25
- Rep Power
- 0
yes I realize that now, and I apologize for that.
But at the time I thought it was a perfectly reasonable statement, I just assumed a Document was a form of File, but obviously I was wrong...
- 03-27-2011, 11:56 AM #16
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Similar Threads
-
How to set Document Filter
By nimishalex in forum New To JavaReplies: 2Last Post: 12-27-2010, 01:08 PM -
How do I substitute any variable for a hardcoded variable
By Weazel Boy in forum New To JavaReplies: 11Last Post: 07-07-2010, 06:02 AM -
Building a document from a DOM
By Java Tip in forum Java TipReplies: 0Last Post: 01-03-2008, 09:22 AM -
Parsed Document
By nick211001 in forum New To JavaReplies: 1Last Post: 07-29-2007, 01:53 AM -
add a xml document
By Jack in forum XMLReplies: 2Last Post: 07-04-2007, 09:21 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks