#33 wrong SWT text widget background color

open
nobody
5
2008-12-15
2008-12-15
No

if a SWT text widget is created like this:

final Text text = new Text(shell, SWT.NONE);

it has a transparent background color in the browser while in "java mode" it is white. Since it has no borders its bounds are not visible (if it has no text it is not visible). You have to set its background explicitly like:

final Text text = new Text(shell, SWT.NONE);
text.setBackground(new Color(shell.getDisplay(), 255,255,255));

if the widget is created with SWT.BORDER like:

final Text text = new Text(shell, SWT.BORDER);

it is shown OK.

I think this is due to the commented line

.text-default {
position:absolute;
border-style:none;
/*background-color:white;*/ <--here

or perhaps due to the following css selector:

.text-no-border {
border-style:none;
background-color:transparent;
}

both in j2slib/org/eclipse/swt/widgets/Text.css

I think a default white background color is much more convenient as a transparent bg color, since with the last, the text widget mey not be seen by the user.

Discussion


Log in to post a comment.