Reputation: 3
Is there any way to create a right aligned multi lined text field in SWT without applying SWT.WRAP style? I need to have the horizontal scroll bar in the text field which disappears when WRAP is used.
Upvotes: 0
Views: 196
Reputation: 36884
Just use SWT.MULTI | SWT.RIGHT
as the style for the Text
:
public static void main(String[] args)
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Text text = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.RIGHT);
text.setText("First line\nsecond line");
shell.open();
shell.pack();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
display.dispose();
}
Looks like this:
Upvotes: 2