S
Sal
In the following test applet, I would like to have the "Begin counting
" display immediately, and the "End counting" to display when
finished, instead the applet waits until the end of the counting loop
and then displays the text all at once. How can I get it to work
properly?
public class Test extends JApplet {
JScrollPane scrollPane;
JTextArea textArea;
Color darkGreen = new Color( 0, 160, 0 ); //medium dark green
int nbrOfTimes = 0x7fffffff;
private void setNativeLookAndFeel() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
textArea.append("Error setting native LAF: " + e + "\n");
}
}
public void init() {
setNativeLookAndFeel();
Container cp = getContentPane();
cp.setBackground( darkGreen );
cp.setLayout( new FlowLayout() );
textArea = new JTextArea(30, 40);
scrollPane = new JScrollPane();
cp.add ( new JScrollPane( textArea ) );
textArea.setEditable( false );
textArea.append( "Begin counting " + nbrOfTimes +" \n" ); //
<------ look here
int ctr = 0;
while( ++ctr < nbrOfTimes );
textArea.append( "End counting " + ctr +" \n" );
// <------- look here
}
}
" display immediately, and the "End counting" to display when
finished, instead the applet waits until the end of the counting loop
and then displays the text all at once. How can I get it to work
properly?
public class Test extends JApplet {
JScrollPane scrollPane;
JTextArea textArea;
Color darkGreen = new Color( 0, 160, 0 ); //medium dark green
int nbrOfTimes = 0x7fffffff;
private void setNativeLookAndFeel() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
textArea.append("Error setting native LAF: " + e + "\n");
}
}
public void init() {
setNativeLookAndFeel();
Container cp = getContentPane();
cp.setBackground( darkGreen );
cp.setLayout( new FlowLayout() );
textArea = new JTextArea(30, 40);
scrollPane = new JScrollPane();
cp.add ( new JScrollPane( textArea ) );
textArea.setEditable( false );
textArea.append( "Begin counting " + nbrOfTimes +" \n" ); //
<------ look here
int ctr = 0;
while( ++ctr < nbrOfTimes );
textArea.append( "End counting " + ctr +" \n" );
// <------- look here
}
}