JEditorPane split
Hi all ,
I have a problem with JEditorPane, I would split it in pages .
I mean , i load a StyledDocument from a file and I would show only a page a time, I tried a copy and paste tecnique .
the whole file is in a JEditorPane and the single page is copied in another JEP that is showed.
this is the code :
publicvoid split(JTextPane from, JTextPane to,int fromWhere ,int toWhere,int jepFromWhere){
from.select(fromWhere,fromWhere+toWhere);
from.copy();
to.setCaretPosition(jepFromWhere);
to.paste();
}
publicvoid setDoc(DefaultStyledDocument document){
this.doc = document;
jep.setVisible(false);
textPaneAppoggio.setDocument(document);
stateChanged=false;
stop =true;
while( how < doc.getLength() && howmuch >0){
split(textPaneAppoggio,jep,how,howmuch,jepHow);
if (stateChanged){
stateChanged =false;
}else{
how = how+howmuch;
jepHow = jepHow+howmuch;
}
}
stop =false;
jep.setVisible(true);
return ;
}
publicvoid adjustmentValueChanged(AdjustmentEvent e){
if(!stateChanged && stop){
jep.setCaretPosition(jep.getDocument().getLength());
if (e.getValue()!=0){
howmuch = 0;
jep.select( how , jep.getCaretPosition() - e.getValue());
jep.cut();
return ;
}
jep.select( how , jep.getCaretPosition() - e.getValue());
jep.cut();
howmuch = howmuch /2;
stateChanged =true;
}
}
thanks for the replies !!!

