MELabel.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:avoCADo 作者:
@Override
void paintElement(PaintEvent e) {
    GC g = e.gc;
    g.setBackground(this.getBackground());
    int width  = this.getBounds().width;
    int height = this.getBounds().height;

    // clear entire canvas where button will be painted
    g.fillRectangle(0, 0, width, height);

    // draw text
    g.setForeground(this.meColorForeground);
    FontData fd = new FontData();
    fd.setHeight(8);
    if(textIsBold){
        fd.setStyle(SWT.BOLD);
    }else{
        fd.setStyle(SWT.NORMAL);
    }
    g.setFont(new Font(this.getDisplay(), fd));
    Point textPt = g.textExtent(this.meLabel);          
    g.drawText(this.meLabel, (width-textPt.x)/2, (height-textPt.y)/2);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号