public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("横线");
shell.setSize(1024,768);
shell.open();
shell.addPaintListener(new PaintListener(){
public void paintControl(PaintEvent e){
int rowx=10,rowy=10,rowx1=1000,rowy1=10;
int listx=10,listy=10,listx1=10,listy1=1000;
GC gc = new GC(shell);
GC gs= new GC(shell);
int ix[]= {10,10,10,20,20,20,20,10};
gc.drawPolygon(ix);
for(int i=0;i<100;i++){
gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
gc.drawRoundRectangle(listx+2, rowy+2, 3, 3,5, 5);//画圆圈
gs.setAlpha(50);//设置透明度。
gs.setForeground(display.getSystemColor(SWT.COLOR_DARK_RED));
gs.drawLine(listx, listy, listx1, listy1);
gs.drawLine(rowx, rowy, rowx1, rowy1);
listx+=10;
listx1+=10;
rowy=rowy+10;
rowy1=rowy1+10;
}
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}这代码能画出线和圆圈,但我想知道怎么画出小叉子来呢?(x)有知道的希望能告诉下,谢谢了
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("横线");
shell.setSize(1024,768);
shell.open();
shell.addPaintListener(new PaintListener(){
public void paintControl(PaintEvent e){
int rowx=10,rowy=10,rowx1=1000,rowy1=10;
int listx=10,listy=10,listx1=10,listy1=1000;
GC gc = new GC(shell);
GC gs= new GC(shell);
int ix[]= {10,10,10,20,20,20,20,10};
gc.drawPolygon(ix);
for(int i=0;i<100;i++){
gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
gc.drawRoundRectangle(listx+2, rowy+2, 3, 3,5, 5);//画圆圈
gs.setAlpha(50);//设置透明度。
gs.setForeground(display.getSystemColor(SWT.COLOR_DARK_RED));
gs.drawLine(listx, listy, listx1, listy1);
gs.drawLine(rowx, rowy, rowx1, rowy1);
listx+=10;
listx1+=10;
rowy=rowy+10;
rowy1=rowy1+10;
}
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}这代码能画出线和圆圈,但我想知道怎么画出小叉子来呢?(x)有知道的希望能告诉下,谢谢了
解决方案 »
- JTabbedPane里的标签
- 100相送,请问如何指定jboss从一个固定目录中导入所有的包?
- 求助关于杨辉三角的问题?
- java同步关键字synchonized是如何实现的 具体的原理是什么?
- 初学,写了个打开图片程序,功能实现了为什么cpu一直是100% 在线
- 没分了,可不可以帮我解决这个数据结构的问题啊???
- 为什么我在JCreator1.52中写好编译运行好的程序,把源文件挪了个地方,用命令行编译运行后变了样?
- 请指教,不甚感激~~ sdk新问题?
- "Integer对象是不可变的"-----关于final和封装器的问题,望高手指点!
- 可以用java applet控制网页上的其它元素吗?
- 一道面试题,做错了
- java List.toArray()的问题
String input="×";
..........
...........
int x = listx;
int y = rowy;
int[] shape = new int[] { x, y, x + 2, y, x + 4, y + 2,
x + 5, y + 2, x + 7, y, x + 9, y, x + 9, y + 2,
x + 7, y + 4, x + 7, y + 5, x + 9, y + 7, x + 9,
y + 9, x + 7, y + 9, x + 5, y + 7, x + 4, y + 7,
x + 2, y + 9, x, y + 9, x, y + 7, x + 2, y + 5,
x + 2, y + 4, x, y + 2 };
gc.fillPolygon(shape);
gc.drawPolygon(shape);
// Draw Fork End
比如上面的代码
x, y是第一个点
x + 2, y, x + 4是第二个点。