|
|
|
|
Re: Multi line label [message #443692 is a reply to message #443689] |
Wed, 29 September 2004 10:57 |
No real name Messages: 21 Registered: July 2009 |
Junior Member |
|
|
Hi Richard,
thank you for your answer. I also tried:
text.setEditable(false);
text.setBackground(white);
instead:
text.setEnabled(false);
Then the background and foreground color is ok but
the text has a cursor and can marked.
While the problem 2 is 'only' ugly, the first one is more important
because the app is for Pocket PC and there space is thinly distributed.
Regards, Tobi
"Richard Moore" <rmoore@infometis.ch> schrieb im Newsbeitrag
news:cje0mk$3hg$1@eclipse.org...
> Hi Tobi,
>
> Try using a text and setting the editable to false, you could even change
> the background color to gray... looks like a label then... I think setting
> enable to false stops the scrolling of a text ? editable I do not know if
> the scrolling still works... try it out.
>
> Regards
> Richard
>
>
> "Tobi Wink" <tobi.winkesf@lycos.com> wrote in message
> news:cjck1d$uh1$1@eclipse.org...
>> Hello,
>>
>> I have to show some name value pairs in a dialog.
>> The dialog has a fixed size (PPC).
>> I used GridLayout with two columns.
>> The scheme is as folowing:
>> date label (1. column) | concrete date (2. column)
>> descr label | description text
>> An example:
>> ...
>> date: 09.25.04
>> description: Now a longer description which
>> contains many words.
>>
>> date: 09.28.04
>> description: Now a longer description which
>> contains many words.
>> ...
>>
>> The problem is the label with the description, which needs
>> often more than one row. I need a multi line label but SWT
>> declared SWT.MULTI not for labels.
>> Thats why, I tried a text field with text.setEnabled(false);
>> for showing the description. But that causes two problems:
>>
>> 1. I have to set the height of the description text field so
>> that the height is sufficient but not bigger.
>> GridData.FILL_VERTICAL lets free space and gridData.heighHint
>> demands the optimal height of the label which I don't know.
>> I tried also with pack() but had no success.
>>
>> 2. The font looks disabled and because I set
>> setEnabled(false) setForeGround(black) and so on has no
>> effect.
>>
>> That seems to be a simple problem but I searched a solution
>> for a long time without result. Does anybody know how I
>> can display multi line labels?
>>
>> Regards, Tobi
>>
>> ************************************************************ ****
>>
>> text = new Text(shell, SWT.MULTI | SWT.WRAP);
>> text.setEnabled(false);
>> text.setText(buffer.toString());
>> gridData = new GridData(GridData.FILL_HORIZONTAL
>> | GridData.FILL_VERTICAL);
>> text.setLayoutData(gridData);
>>
>>
>>
>
>
|
|
|
Re: Multi line label [message #443696 is a reply to message #443692] |
Wed, 29 September 2004 12:04 |
Benjamin Pasero Messages: 337 Registered: July 2009 |
Senior Member |
|
|
Here is a possible solution that is using the StyledText widget
from the SWT custom package:
public class Main {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final StyledText st = new StyledText(shell, SWT.MULTI | SWT.READ_ONLY);
st.setText("Hello World");
st.setCursor(display.getSystemCursor(SWT.CURSOR_ARROW));
st.setCaret(null);
st.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
st.setSelection(0);
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}
Just set the background to gray or something like that.
> Hi Richard,
> thank you for your answer. I also tried:
> text.setEditable(false);
> text.setBackground(white);
> instead:
> text.setEnabled(false);
> Then the background and foreground color is ok but
> the text has a cursor and can marked.
> While the problem 2 is 'only' ugly, the first one is more important
> because the app is for Pocket PC and there space is thinly distributed.
> Regards, Tobi
> "Richard Moore" <rmoore@infometis.ch> schrieb im Newsbeitrag
> news:cje0mk$3hg$1@eclipse.org...
> > Hi Tobi,
> >
> > Try using a text and setting the editable to false, you could even change
> > the background color to gray... looks like a label then... I think setting
> > enable to false stops the scrolling of a text ? editable I do not know if
> > the scrolling still works... try it out.
> >
> > Regards
> > Richard
> >
> >
> > "Tobi Wink" <tobi.winkesf@lycos.com> wrote in message
> > news:cjck1d$uh1$1@eclipse.org...
> >> Hello,
> >>
> >> I have to show some name value pairs in a dialog.
> >> The dialog has a fixed size (PPC).
> >> I used GridLayout with two columns.
> >> The scheme is as folowing:
> >> date label (1. column) | concrete date (2. column)
> >> descr label | description text
> >> An example:
> >> ...
> >> date: 09.25.04
> >> description: Now a longer description which
> >> contains many words.
> >>
> >> date: 09.28.04
> >> description: Now a longer description which
> >> contains many words.
> >> ...
> >>
> >> The problem is the label with the description, which needs
> >> often more than one row. I need a multi line label but SWT
> >> declared SWT.MULTI not for labels.
> >> Thats why, I tried a text field with text.setEnabled(false);
> >> for showing the description. But that causes two problems:
> >>
> >> 1. I have to set the height of the description text field so
> >> that the height is sufficient but not bigger.
> >> GridData.FILL_VERTICAL lets free space and gridData.heighHint
> >> demands the optimal height of the label which I don't know.
> >> I tried also with pack() but had no success.
> >>
> >> 2. The font looks disabled and because I set
> >> setEnabled(false) setForeGround(black) and so on has no
> >> effect.
> >>
> >> That seems to be a simple problem but I searched a solution
> >> for a long time without result. Does anybody know how I
> >> can display multi line labels?
> >>
> >> Regards, Tobi
> >>
> >> ************************************************************ ****
> >>
> >> text = new Text(shell, SWT.MULTI | SWT.WRAP);
> >> text.setEnabled(false);
> >> text.setText(buffer.toString());
> >> gridData = new GridData(GridData.FILL_HORIZONTAL
> >> | GridData.FILL_VERTICAL);
> >> text.setLayoutData(gridData);
> >>
> >>
> >>
> >
> >
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03396 seconds