Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 15:58 Go to next message
ouri.maler is currently offline ouri.malerFriend
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 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
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?
Previous Topic:Table Accessibility in 3.6 Helios SWT
Next Topic:AbstractPropertySection and wrapping
Goto Forum:
  


Current Time: Thu Apr 25 20:11:13 GMT 2024

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

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

Back to the top