Label.setImage() and Lable.setText() [message #450745] |
Thu, 17 February 2005 15:33 |
Eclipse User |
|
|
|
Originally posted by: johns.atwork.comhem.se
Hi!
I am new to SWT.
I have been reading a book on SWT and have started
going through the examples and have a question about
the behavior of Label. (or maybe the question applies to Shell)
As I understand it, one can use setImage() and/or setText()
to set these attributes of a Label and the last one set will
be the one displayed. Text will be displayed if the order is
...
myLable.setImage(someImage);
myLable.setText("Some text.");
...
and an image will be displayed if the order is
...
myLable.setText("Some text.");
myLable.setImage(someImage);
...
First question: Is my assumtion correct?
The second question has the following setup.
If I start with the following code:
...
String sTextA = "Some text.";
String sTextB = "Some other text.";
...
myLable.setText(sTextA);
myLable.setImage(someImage);
...
and then display it I will see the image, someImage.
If this follows later in the code:
...
myLable.setImage(someImage);
myLable.setText(sTextA);
...
the result displayed will be the image, someImage.
The appearent reason for this is that nothing at all
happens when the text being set is an exact match
of the text already there. The intention was to bring
forward the text but this cannot be done in that manner.
I discoverd this because the following:
...
myLable.setImage(someImage);
myLable.setText(sTextB);
...
results in sTextB being displayed.
(because sTextB is a different string from sTextA).
Note that if:
String sTextB = "Some text."; (i.e the same string as sTextA)
then the result will still be the image, someImage, being displayed.
Second question: Is that the correct behavior?
Thanks in advance!
/John
|
|
|
|
Powered by
FUDForum. Page generated in 0.02038 seconds