分享

(DM)用DRAW2D画多边形的例子

 jinzq 2007-06-12
public class Polygon{

   public static void main(String[] args) {
       final Display display = Display.getDefault();
       final Shell shell = new Shell();
       shell.setSize(500, 375);
       shell.setText("SWT Application");
       LightweightSystem lws = new LightweightSystem(shell);
       Figure contents = new Figure();
       XYLayout contentsLayout = new XYLayout();
       contents.setLayoutManager(contentsLayout);
       
       Polygon p1 = new Polygon();
       PointList list = new PointList();
       list.addPoint(160, 0);
       list.addPoint(240, 80);
       list.addPoint(320, 80);
       list.addPoint(240, 0);
       p1.setPoints(list);
       p1.setBackgroundColor(display.getSystemColor(SWT.COLOR_BLUE));
       contents.add(p1);
       p1.setFill(true);//使设置背景色生效【p1.setBackgroundColor(display.getSystemColor(SWT.COLOR_BLUE)); 】
       
       lws.setContents(contents);
       shell.open();
       shell.layout();
       while (!shell.isDisposed()) {
           if (!display.readAndDispatch())
               display.sleep();
       }
   }
}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多