This code should give you an idea. It has two Text
widgets. One of them will act as a console (text appended) and the other one will show the last text you added to the console. Just click the button to add text:
public static void main(String[] args)
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("StackOverflow");
shell.setLayout(new FillLayout(SWT.VERTICAL));
final Text text = new Text(shell, SWT.MULTI | SWT.WRAP);
text.setEditable(false);
final Text lastAppend = new Text(shell, SWT.BORDER);
lastAppend.setEditable(false);
Button button = new Button(shell,SWT.PUSH);
button.setText("Add new line");
button.addListener(SWT.Selection, new Listener()
{
private int counter = 0;
@Override
public void handleEvent(Event arg0)
{
String append = "TEST " + counter++ + "\n";
text.append(append);
lastAppend.setText(append);
}
});
shell.pack();
shell.setSize(300, 300);
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
Looks like this: