Hi all,

I've been searching for some time without any success. Here's the problem: I have an SWT GUI, which contains some UI elements placed onto a Composite. I would like to dynamically add a new Composite to the old one, when a certain event is triggered. Fine everything works just fine, however, the new composite appears only when I resize my window. Tried redrawing the window, not much luck though. Is there any special way to do this?

Thanks,
Chaster

Recommended Answers

All 3 Replies

call pack on the frame in which the component resides

or

call doLayout (and/or validate) on the component to which the component was added and then repaint

Edit: Although, in the second scenario, the layout of the frame itself (if the size of "subcomponent" has changed) will also, still need to be updated, so maybe simply call pack on the Frame or doLayout on the contentPane of the frame.

commented: Short, very good answer, that solves the issue. +3

That did the trick, thank you.

Chaster

call pack on the frame in which the component resides

or

call doLayout (and/or validate) on the component to which the component was added and then repaint

Edit: Although, in the second scenario, the layout of the frame itself (if the size of "subcomponent" has changed) will also, still need to be updated, so maybe simply call pack on the Frame or doLayout on the contentPane of the frame.

Thanks very much this was very helpful for me too. :)

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.