提升边境SWT / JFace

时间:2012-07-02 12:50:39

标签: swt eclipse-rcp jface

我似乎无法找到有关如何在Eclipse RCP中添加不同类型边框的在线帮助。我知道Swing有BevelBorder可以使用BorderFactory实现。任何swt等价?

2 个答案:

答案 0 :(得分:3)

试试这个样式:SWT.SHADOW_IN,SWT.SHADOW_OUT,SWT.SHADOW_ETCHED_IN,SWT.SHADOW_ETCHED_OUT

答案 1 :(得分:1)

请将此方法用于斜角边框

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);
    }
}