Member Avatar for robv

Hi all,

I'm a newbie for SWT, all was fine until now.
I got a simple app with some buttons and text fields. I'd like to update the text field with incoming messages and show it to the user.

Display display = new Display();
Shell shell = new Shell(display);

messageField = new Text (shell, SWT.BORDER);
messageField.setBounds(10, 100, 150, 100);
messageField.setEditable(false);

messageField.append("1st");


shell.setBounds(10, 10, 600, 1400);
shell.pack ();

shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}

display.dispose ();
		
messageField.append("2nd");

Now, I can see "1st" but not "2nd" because it's called after the display.dispose ();
OK, but how can I update a text field after the app is shown on the screen?

Thanks in advance

#
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}

display.dispose ();

while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        // If no more entries in event queue
        display.sleep();
      }
    }

private void init() {
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.