sonx
sonx

Reputation: 661

raised border SWT/JFace

i can't seem to find online help on how to add different type of borders in Eclipse RCP. I know Swing has BevelBorder which can be achieved using BorderFactory. Any swt equivalence?

Upvotes: 0

Views: 350

Answers (2)

Shashwat
Shashwat

Reputation: 2352

Please use this method for Bevel Border

private void drawBorders(GC gc, int x, int y, int w, int h) {
    final Display disp = getDisplay();
    final Color topleft = disp.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
    final Color bottomright = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
    if (topleft != null && bottomright != null) {
        gc.setLineWidth(1);
        gc.setForeground(bottomright);
        gc.drawLine(x + w, y, x + w, y + h);
        gc.drawLine(x, y + h, x + w, y + h);

        gc.setForeground(topleft);
        gc.drawLine(x, y, x + w - 1, y);
        gc.drawLine(x, y, x, y + h - 1);
    }
}

Upvotes: 1

dragn
dragn

Reputation: 1050

Try this styles: SWT.SHADOW_IN, SWT.SHADOW_OUT, SWT.SHADOW_ETCHED_IN, SWT.SHADOW_ETCHED_OUT

Upvotes: 3

Related Questions