Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Can't access Label(...at least, where I need to.)
Can't access Label [message #653667] Thu, 10 February 2011 10:58 Go to next message
Eclipse UserFriend
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 10:14 Go to previous message
Eclipse UserFriend
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?
Previous Topic:Table Accessibility in 3.6 Helios SWT
Next Topic:AbstractPropertySection and wrapping
Goto Forum:
  


Current Time: Thu Jul 03 15:18:05 EDT 2025

Powered by FUDForum. Page generated in 0.23971 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top