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 [email]freesoft_2000@yahoo.com[/email]
Thank You
Your Sincerely
Richard West