凸起的边界SWT/JFace



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

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

请将此方法用于斜角边框

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

最新更新