ranlineobj.java

来自「一个基于swing的网络白板」· Java 代码 · 共 37 行

JAVA
37
字号
package mywb;import java.awt.*;
import java.io.*;
import java.util.*;public class RanLineObj implements Serializable {  Vector points = new Vector();  Color color = null;  int x0 , y0 , x1 , y1;  public static int type = 8 ;  public RanLineObj(Color c){    color = c;  }  public void setPoints(int x, int y){    Point point = new Point(x,y);    points.add(point);  }  public void paint(Graphics g){     g.setColor (color);     Enumeration allpoints = points.elements();     Point start = (Point)allpoints.nextElement();     x0 = (int)start.getX();     y0 = (int)start.getY();     while(allpoints.hasMoreElements()){          Point end = (Point)allpoints.nextElement();          x1 = (int)end.getX();          y1 = (int)end.getY();          g.drawLine(x0,y0,x1,y1);          x0 = x1;          y0 = y1;     }  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?