[英]draw a round rectangle with gradient
I want to draw a round rectangle in SWT like this one 我想像这样在SWT中绘制一个圆形矩形
I couldn't found a way to do this, and I decide to throw my code away and ask here :( 我找不到执行此操作的方法,因此我决定丢掉我的代码,然后在这里问:(
any thoughts? 有什么想法吗?
Thanks :D 感谢:D
Edit 编辑
I tried again, this is what I have for now 我再次尝试过,这是我现在拥有的
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.wb.swt.SWTResourceManager;
public class TesteGradient extends Canvas {
Color COLOR_TOP = SWTResourceManager.getColor(166, 166, 166);
Color COLOR_BOTTOM = SWTResourceManager.getColor(241, 241, 241);
private boolean selected = false;
public TesteGradient(Composite parent, int style) {
super(parent, style);
this.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.setAntialias(SWT.ON);
e.gc.setBackground(COLOR_BOTTOM);
e.gc.setForeground(COLOR_TOP);
e.gc.fillGradientRectangle(0, 0,93, 27, true);
e.gc.setClipping(0, 0, 4, 4);
}
});
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
}
The corret URL is https://github.com/germantech/ios-widgets . 正确的URL是https://github.com/germantech/ios-widgets 。 We've built a small suit of components
我们已经构建了一套小型组件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.