[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Background Color (return to default behavior after change)
|
Hello all -
I have an org.eclipse.swt.widgets.Canvas. I need to be able to change the
background color on the Canvas, and then later return it to it's "default"
state. I'm doing this:
Canvas canvas = new Canvas(parent, SWT.NONE);
..
Color previousColor = canvas.getBackground();
canvas.setBackground(SWT.COLOR_DARK_GRAY);
..
canvas.setBackground(previousColor);
However, when this completes, the background is visibly not the same as it
was prior.
Inspection reveals that the "background" field on canvas initializes to
the value "-1" (which presumably means "do the default.") However, after
the code above runs, the value IS NOT "-1". And, of course, because
setBackground takes a Color as an argument, I don't think I can set it
back to "-1". This is especially troublesome in cases where the Canvas is
in an ExpandItem (for example), because the background is not a "flat"
color - instead, it is an OS provided background, so I can't even emulate
the behavior by using a "similar" color.
If it would help, I can provide a complete test case.
Thanks for any guidance,
jared