Buttons don't display until window is resized [message #529263] |
Fri, 23 April 2010 16:21 |
Herb Miller Messages: 139 Registered: January 2010 |
Senior Member |
|
|
I have a view that has been allowed only a small portion of the perspective real estate. The view has a Composite on a ScrolledComposite on the parent Composite in createPartControl. The child Composite has a GridLayout(2,true). The ScrolledComposite has a resize listener.
This view displays 2 columns of buttons, one button for each new request received (per requirements). I do not know how many are coming in, so I start with a large ArrayList of buttons, invisible at first, but made visible as requests come in. These all display perfectly, the scroll bar works - everything is great.
However, eventually one more request comes in than I have buttons, but there are arrangements to new up buttons and add them to the array list. The problem is that even though the new buttons are created on the child Composite, they do not display.
I tried the following and it sort of works. I called the ScrolledComposite setMinSize and passed in the child Composite's recomputed size.
This does allow the 1st new button in the left column to be displayed, even though it resizes all previous buttons to be smaller. So it looks weird.
But it will not display the next button that is displayed in the right column. I guess because the size has not changed. However, if another left column button comes in, then the new left column button and the previous right column button are displayed at the same time.
If a new left column button never comes in, the last right column button is never displayed. However, if I resize the edge of my view after the new right column button has been put on the child Composite, the right column button will display.
What can I do to fix this?
Thanks.
|
|
|
|
|
Re: Buttons don't display until window is resized [message #529875 is a reply to message #529327] |
Tue, 27 April 2010 14:18 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi,
I think the following demonstrates what you want, unless I parsed your
description wrong. If this does not match what you want to do then can you
add a few more words or lines to the snippet to clarify what's needed?
public class ModifiedSnippet188 {
static int buttonCount = 0;
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new GridLayout(2, false));
final ScrolledComposite sc = new ScrolledComposite(shell, SWT.BORDER |
SWT.H_SCROLL | SWT.V_SCROLL);
sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
final Composite composite = new Composite(sc, SWT.NONE);
composite.setLayout(new GridLayout(2, true));
for (int i = 0 ; i < 30; i++) {
new Button(composite, SWT.PUSH).setText("Button "+i);
}
buttonCount = 30;
sc.setContent(composite);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
Button addButtons = new Button(shell, SWT.PUSH);
addButtons.setText("Add 5 Buttons");
addButtons.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
for (int i = buttonCount; i < buttonCount + 5; i++) {
new Button(composite, SWT.NONE).setText("button " + i);
}
buttonCount += 5;
sc.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
});
shell.setSize(300, 300);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
HTH,
Grant
"Herb Miller" <herbmiller7@gmail.com> wrote in message
news:hqsv6r$n98$1@build.eclipse.org...
> Oh my goodness - I added a control listener to every button to set the
size back to the desired size, and it works.
>
> But, man - what a flicker rate, even with just 2 buttons.
>
> Is there some way to eliminate the flicker? Is there a way to know when
the last resize event happens at the end of a resize?
>
> There has got to be some way to keep the flicker down.
>
> Thanks.
>
|
|
|
Powered by
FUDForum. Page generated in 0.04300 seconds