| | |
Documents
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
hi everyone,
I have a textpane using the default styled document. This textpane contains a icon and some formatted text. Next i have a file saved to my disk which is a document of another textpane. What i want to do is be able to append the two documents together and make those two documents into one document.
Can someone show me any codings or explain me how this can actually achieved.
My e-mail is freesoft_2000@yahoo.com
Yours Sincerely
Richard West
I have a textpane using the default styled document. This textpane contains a icon and some formatted text. Next i have a file saved to my disk which is a document of another textpane. What i want to do is be able to append the two documents together and make those two documents into one document.
Can someone show me any codings or explain me how this can actually achieved.
My e-mail is freesoft_2000@yahoo.com
Yours Sincerely
Richard West
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
hi everyone,
This is as far as i have gotten. The below class compiles without any errors but it still does not work. Maybe some one can check and see what i am doing wrong in my code. The document i am using is from a textpane that i have somewwhere else and then call this class in to do some clip board operations for me.
The values i passed into the class is as follows:
JDocumentClipboard Clip1 = new JDocumentClipboard();
Document Doc1;
int a1, b1, c1, d1;
Doc1 = TextPane1.getDocument();
a1 = TextPane1.getSelectionStart();
b1 = TextPane1.getSelectionEnd();
c1 = Doc1.getLength();
d1 = TextPane1.getCaretPosition();
Clip1.documentvalues(Doc1, a1, b1, c1, d1);
Clip1.documentcopy();
The below class is the class that doe most of the manipulation but does not seem to work
public class JDocumentClipboard
{
Document Doc2;
int a, b, c, d;
public void documentvalues (Document Doc1, int a1, int b1, int c1, int d1)
{
Doc2 = Doc1;
a = a1;
b = b1;
c = c1;
d = d1;
}
public Document documentparse ()
{
Document Doc3;
Doc3 = Doc2;
try
{
Doc3.remove(0, a - 1);
Doc3.remove(b + 1, c);
}
catch (BadLocationException e)
{
}
return Doc3;
}
public Document documentupper ()
{
Document Doc4;
Doc4 = Doc2;
try
{
Doc4.remove(d, c);
}
catch (BadLocationException e)
{
}
return Doc4;
}
public Document documentlower ()
{
Document Doc5;
Doc5 = Doc2;
try
{
Doc5.remove(0, d);
}
catch (BadLocationException e)
{
}
return Doc5;
}
public void documentcopy ()
{
Document Doc6, Doc7, Doc8;
Doc6 = documentupper();
Doc7 = documentparse();
Doc8 = documentlower();
try
{
File file1 = new File("C:/Clip.dat");
FileOutputStream fStream = new FileOutputStream(file1);
ObjectOutput stream = new ObjectOutputStream(fStream);
stream.writeObject(Doc6);
stream.writeObject(Doc7);
stream.writeObject(Doc8);
stream.flush();
stream.close();
fStream.close();
}
catch (Exception e)
{
}
}
public Document documentpaste ()
{
Document Doc9 = null;
try
{
File file2 = new File("C:/Clip.dat");
FileInputStream fStream = new FileInputStream(file2);
ObjectInput stream = new ObjectInputStream(fStream);
Object obj = stream.readObject();
if(obj instanceof Document)
{
Doc9 = ((Document) obj);
}
stream.close();
fStream.close();
}
catch (Exception e)
{
}
return Doc9;
}
}
Maybe someone can help me with this problem as i don't really know what i have done wrong
My e-mail is freesoft_2000@yahoo.com
Thank You
Your Sincerely
Richard West
This is as far as i have gotten. The below class compiles without any errors but it still does not work. Maybe some one can check and see what i am doing wrong in my code. The document i am using is from a textpane that i have somewwhere else and then call this class in to do some clip board operations for me.
The values i passed into the class is as follows:
JDocumentClipboard Clip1 = new JDocumentClipboard();
Document Doc1;
int a1, b1, c1, d1;
Doc1 = TextPane1.getDocument();
a1 = TextPane1.getSelectionStart();
b1 = TextPane1.getSelectionEnd();
c1 = Doc1.getLength();
d1 = TextPane1.getCaretPosition();
Clip1.documentvalues(Doc1, a1, b1, c1, d1);
Clip1.documentcopy();
The below class is the class that doe most of the manipulation but does not seem to work
public class JDocumentClipboard
{
Document Doc2;
int a, b, c, d;
public void documentvalues (Document Doc1, int a1, int b1, int c1, int d1)
{
Doc2 = Doc1;
a = a1;
b = b1;
c = c1;
d = d1;
}
public Document documentparse ()
{
Document Doc3;
Doc3 = Doc2;
try
{
Doc3.remove(0, a - 1);
Doc3.remove(b + 1, c);
}
catch (BadLocationException e)
{
}
return Doc3;
}
public Document documentupper ()
{
Document Doc4;
Doc4 = Doc2;
try
{
Doc4.remove(d, c);
}
catch (BadLocationException e)
{
}
return Doc4;
}
public Document documentlower ()
{
Document Doc5;
Doc5 = Doc2;
try
{
Doc5.remove(0, d);
}
catch (BadLocationException e)
{
}
return Doc5;
}
public void documentcopy ()
{
Document Doc6, Doc7, Doc8;
Doc6 = documentupper();
Doc7 = documentparse();
Doc8 = documentlower();
try
{
File file1 = new File("C:/Clip.dat");
FileOutputStream fStream = new FileOutputStream(file1);
ObjectOutput stream = new ObjectOutputStream(fStream);
stream.writeObject(Doc6);
stream.writeObject(Doc7);
stream.writeObject(Doc8);
stream.flush();
stream.close();
fStream.close();
}
catch (Exception e)
{
}
}
public Document documentpaste ()
{
Document Doc9 = null;
try
{
File file2 = new File("C:/Clip.dat");
FileInputStream fStream = new FileInputStream(file2);
ObjectInput stream = new ObjectInputStream(fStream);
Object obj = stream.readObject();
if(obj instanceof Document)
{
Doc9 = ((Document) obj);
}
stream.close();
fStream.close();
}
catch (Exception e)
{
}
return Doc9;
}
}
Maybe someone can help me with this problem as i don't really know what i have done wrong
My e-mail is freesoft_2000@yahoo.com
Thank You
Your Sincerely
Richard West
![]() |
Similar Threads
- Unable to access my computer, my documents, and control from start bar and run!! (Windows NT / 2000 / XP)
- can only open my documents after connecting to internet (Web Browsers)
- Remove Record of Recently Used Documents (Windows tips 'n' tweaks)
- my computer, my documents, etc.. folders do not open (Windows NT / 2000 / XP)
- MY Documents (Windows NT / 2000 / XP)
Other Threads in the Java Forum
- Previous Thread: Can any1 help me...this is urgent
- Next Thread: twenty integers in an array
Views: 1401 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Java
3d @param affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth byte c# chat class classes click client code color compare component corrupted database detection draw eclipse error event exception file fractal game givemetehcodez graphics gui guitesting helpwithhomework html ide image input integer j2me java java.xls javaprojects jmf jni jpanel julia keytool keyword linux list loop map method methods mobile netbeans newbie number object oracle pong print problem producer program programming project projectideas read recursion reflection rim scanner screen server set size sms socket sort sql string swing terminal test threads time transfer tree web windows





