Can't access Label [message #653667] |
Thu, 10 February 2011 15:58 |
ouri.maler Messages: 22 Registered: July 2010 |
Junior Member |
|
|
I'm having a weird problem with the interface I'm coding. I've recently added a set of progress bars, and I want to have a text Label right next to one of them explaining its function.
At the start of the Class, I declare various global variables:
ProgressBar secondaryProgressBar;
shell progressShell;
Label label;
Later, I have the method that opens the new shell for the progress bar:
public void launchProgressBar(String name)
{
progressShell = new Shell(display);
secondaryProgressBar = new progressBar(progressShell, SWT.NONE);
label = new Label(progressShell, SWT.NULL);
[...]
}
Then, in the method that launches the secondary progress bar...
public void launchSecondaryProgressBar()
{
label.setText("whatever");
//several more operations on label go here
secondaryProgressBar.setSelection(0);
}
Thing is...If I include operations on the label object in the launchProgressBar() method, they work just fine. If I include them in launchSecondaryProgressBar(), as shown here, nothing happens (even though it has no trouble working on the secondaryProgressBar object). Does anyone have any idea why that is?
|
|
|
Re: Can't access Label [message #654654 is a reply to message #653667] |
Wed, 16 February 2011 15:14 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
To confirm, you're saying that in launchSecondaryProgressBar(),
label.setText(...) does not succeed in changing the text of the Label from
launchProgressBar(), right? Assuming that there isn't something "unrelated"
happening (eg.- "label" is mistakenly actually referring to a different
Label, or setRedraw(false) has been called, or...), then my only guess is
that perhaps launchSecondaryProgressBar() is being invoked at a time when
the UI thread is being starved, so it's not getting a chance to redraw the
label with its new value (?). Is whatever task you're displaying progress
for happening in the main thread or a background thread? It's difficult to
make a better guess than this given the problem's limited description.
Possibly relevant snippets:
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.sn ippets/src/org/eclipse/swt/snippets/Snippet56.java?view=co
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.sn ippets/src/org/eclipse/swt/snippets/Snippet57.java?view=co
HTH,
Grant
<ouri.maler@gmail.com> wrote in message
news:ij11j7$kdp$1@news.eclipse.org...
> I'm having a weird problem with the interface I'm coding. I've recently
> added a set of progress bars, and I want to have a text Label right next
> to one of them explaining its function.
>
> At the start of the Class, I declare various global variables:
>
> ProgressBar secondaryProgressBar;
> shell progressShell;
> Label label;
>
> Later, I have the method that opens the new shell for the progress bar:
>
> public void launchProgressBar(String name)
> {
> progressShell = new Shell(display);
> secondaryProgressBar = new progressBar(progressShell, SWT.NONE);
> label = new Label(progressShell, SWT.NULL);
> [...]
> }
>
> Then, in the method that launches the secondary progress bar...
>
> public void launchSecondaryProgressBar()
> {
> label.setText("whatever");
> //several more operations on label go here
> secondaryProgressBar.setSelection(0);
> }
>
> Thing is...If I include operations on the label object in the
> launchProgressBar() method, they work just fine. If I include them in
> launchSecondaryProgressBar(), as shown here, nothing happens (even though
> it has no trouble working on the secondaryProgressBar object). Does anyone
> have any idea why that is?
|
|
|
Powered by
FUDForum. Page generated in 0.02961 seconds