我不能提供一个SSCCE,因为我不能让错误重复我的大应用程序之外。
但这里是一个片段,并输出:
if (vp != null) {
try {
starterModule.writePaneln("Sigma.show() 4.1 vp: "+vp);
starterModule.writePaneln("Sigma.show() 4.1 P: "+P);
starterModule.writePaneln("Sigma.show() 4.1 scrollPane: "+scrollPane);
vp.setView(P);
starterModule.writePaneln("Sigma.show() 4.2");
} catch (Exception e) {
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("C:\\javaout2.txt", true)));
out.println("ERROR SIGMA e:");
out.flush();
out.close();
}
}
输出是:
Sigma.show() 4.1 vp: javax.swing.JViewport[,0,0,902x800,layout=javax.swing.ViewportLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=25165832,maximumSize=,minimumSize=,preferredSize=,isViewSizeSet=true,lastPaintPosition=,scrollUnderway=false]
Sigma.show() 4.1 P: javax.swing.JPanel[,0,0,0x0,invalid,layout=javax.swing.BoxLayout,alignmentX=0.0,alignmentY=0.0,border=com.devexperts.dxpro.shared.swing.styles.support.border.DefaultBorderSetter$PaddingBorder@4719dad8,flags=9,maximumSize=,minimumSize=,preferredSize=]
Sigma.show() 4.1 scrollPane: javax.swing.JScrollPane[,0,30,917x800,layout=javax.swing.ScrollPaneLayout$UIResource,alignmentX=0.0,alignmentY=0.0,border=com.devexperts.dxpro.shared.swing.styles.support.border.DefaultBorderSetter$PaddingBorder@14716d46,flags=328,maximumSize=,minimumSize=,preferredSize=,columnHeader=,horizontalScrollBar=javax.swing.JScrollPane$ScrollBar[,0,0,0x0,hidden,layout=com.devexperts.dxpro.shared.swing.styles.laf.impl.basic.StyledScrollBarUI,alignmentX=0.0,alignmentY=0.0,border=,flags=4194632,maximumSize=,minimumSize=,preferredSize=,blockIncrement=10,orientation=HORIZONTAL,unitIncrement=1],horizontalScrollBarPolicy=HORIZONTAL_SCROLLBAR_AS_NEEDED,lowerLeft=,lowerRight=,rowHeader=,upperLeft=,upperRight=,verticalScrollBar=javax.swing.JScrollPane$ScrollBar[,902,0,15x800,layout=com.devexperts.dxpro.shared.swing.styles.laf.impl.basic.StyledScrollBarUI,alignmentX=0.0,alignmentY=0.0,border=,flags=4194632,maximumSize=,minimumSize=,preferredSize=,blockIncrement=10,orientation=VERTICAL,unitIncrement=1],verticalScrollBarPolicy=VERTICAL_SCROLLBAR_ALWAYS,viewport=javax.swing.JViewport[,0,0,902x800,layout=javax.swing.ViewportLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=25165832,maximumSize=,minimumSize=,preferredSize=,isViewSizeSet=true,lastPaintPosition=,scrollUnderway=false],viewportBorder=]
然后该程序似乎冻结vp.setView(P); 作为下一个writePaneln不叫。
但是,错误也不会被困住....
这里writePaneln(出于完整性)
public static void writePaneln(String txt){
if(DEBUG){
try {
synchronized (textPane) {
//textPane.getDocument().insertString(textPane.getDocument().getLength(), txt + "\n", null);
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("C:\\javaout.txt", true)));
out.println(txt);
out.flush();
out.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
JOptionPane.showMessageDialog(null,"writePaneln ERROR: "+e);
}
}
}
编辑1
我已经改变了对我的java.util.Timer中使用的invokeLater:
class RemindTask extends TimerTask {
@Override
public void run() {
SwingUtilities.invokeLater(
new Runnable(){
@Override
public void run() {
handleGO();
};
}
);
}
}