Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] cannot append text in infinite loop

Hello,

I am new to swt and have been working on application which gathers string
from a jni call froma serial port and displays it on a text widget. the code
is attached below

Display display = new Display();
final Shell shell = new Shell(display,SWT.RESIZE);
shell.setSize(320, 240);
shell.setLayout(null);	
Font font1 = new Font(display, "UTF-8", 5, SWT.NORMAL);
final Text text = new Text(shell,SWT.MULTI|SWT.WRAP|SWT.V_SCROLL);
text.setBounds(new Rectangle(3, 8, 308, 201));
text.setEditable(false);
text.setFont (font1);
text.append ("tags \n");//the text widget is able to display this



while (true) {

wait();
if (i==1) // the code waits in infinite loop polling for the flag to be set
high
{

System.out.print(s); 
/*s is the string which gets updated . this command does print out the
string on console every time without any problem*/
System.out.println("\n");
text.append(s + "\n");
shell.pack();
shell.open();
shell.layout(true);
i=0;

}

}

The above code runs as a thread. The first time the flag is set i can see
the string displayed on screen teh first time. but subsequent updates of the
string fail. I am not sure if teh display hangs up after that. can anyone
tell me where i am going wrong
-- 
View this message in context: http://www.nabble.com/cannot-append-text-in-infinite-loop-tp15818289p15818289.html
Sent from the Eclipse Platform - swt mailing list archive at Nabble.com.



Back to the top