I'm trying to implement a simple SWT dialog, which has a text field and if there is something wrong in the entered text of the text field, I want to show this error in a label at the bottom of the text field.
So in the beginning you see only the text field, which is filling the whole window. If I show the label, I create it and want to show it at the bottom of the text field.
My problem is, that you only see this label after resizing the window (all the same whether I make it smaller or bigger). So which method is called in the shell, when I resize the window?
I tried:
shell.layout();
shell.update();
shell.pack();
shell.redraw();
textField.update();
textField.redraw();
But nothing changed.
So the only possibility that worked was to take:
Point oldSize = shell.getSize();
oldSize.x += 1;
shell.setSize(oldSize);
oldSize.x -= 1;
shell.setSize(oldSize);
But this is not an acceptable solution, because the user notices the small changing of the size of the shell. My question is similar to this: Java SWT added Label not visible (also the application looks very similar), but in this solution with pack and setting the old size, the user notices the resizing, and this is very unsatisfying for me.
So do you know, which method I could call to update the window, like when I resize? But in this way the size of the window stays the same?
Thank you!
Edit: If I create the label in the beginning ans set it as invisible, you notice that there is something:
Example: this picture shows the window part without creating the label and setting it to invisible
This picture shows the window part with creating the label and setting it to invisible:
I would prefer version 1.