addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
GC gc = e
Point size = getSize();
int beginx = e
int beginy = (e
int beginLine = (e
int endLine = beginLine + e
if (endLine > getItemCount())
endLine = getItemCount();
for (int i = beginLine; i < endLine; i++) {
boolean selected = false;
if (i == rowSel)
selected = true;
onPaint(gc
selected);
}
}
});
這裡要注意的是從PaintEvent中獲取的x
接下來
addListener(SWT
public void handleEvent(Event event) {
switch (event
case SWT
if (rowSel !=
oldRowSel = rowSel;
rowSel
if (oldRowSel != rowSel) { //發送消息讓控件重繪
((Canvas) event
/ lineHeight)
* lineHeight
}
if (rowSel <
ScrollBar bar = ((Canvas) event
bar
scrollVertical(bar);
}
selectionChanged(); // 發送selectionChanged事件
}
break;
case SWT
…
break;
}
}
});
接下來
[
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28985.html