I seem to have run into a snag replacing text in a JTextPane. I have a couple of JTextPanes that I need to change the exiting text. I can do this with initial text but when I call to change the document, I see this change in the call but the panel will not update.
switch(module.getCurrentQuestionNumber())
{
case 1:
doc = module8.loadQuestion1();
udoc = module8.loadQuestion1();
codeTextPane.setDocument(doc);
uCodeTextPane.setDocument(udoc);
toolPane.add(module.loadQuestion1Panel(outputTextPane));
uToolPane.add(module.loadQuestion1Panel(uOutputTextPane));
break;
case 2:
doc = module8.loadQuestion2();
udoc = module8.loadQuestion2();
codeTextPane.setDocument(doc);
uCodeTextPane.setDocument(udoc);
toolPane.add(module.loadQuestion2Panel(outputTextPane));
uToolPane.add(module.loadQuestion2Panel(uOutputTextPane));
break;
}
When module.getCurrentQuestionNumber()
returns 1 the panels load and everything works as intended. When module.getCurrentQuestionNumber()
returns 2, both doc & udoc has the correct information in it (I stepped through the program and when I get to the call in case 2 the docs show the updated question), but this will not update the codeTextPane, nor will the toolPane load the new panels. I tried to call repaint() and update() and neither seems to work. Am I missing something?