首先,你的建立一个坐标系,把你的数据对应成点,映射到这个坐标系中。然后用Graphics类中的drawLine()方法,用直线依次把这些点连起来就行了。

解决方案 »

  1.   

    你说清楚点吧,比如是否一定要在paint()中调用drawline方法?我想在一个新的internalframe中划线,如何调paint()方法?xie xie!
      

  2.   

    /*
     * @(#)GraphApplet.java 1.5 01/12/03
     *
     * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
     * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
     */import java.awt.Graphics;public class GraphApplet extends java.applet.Applet {
        double f(double x) {
    return (Math.cos(x/5) + Math.sin(x/7) + 2) * getSize().height / 4;
        }    public void paint(Graphics g) {
            for (int x = 0 ; x < getSize().width ; x++) {
        g.drawLine(x, (int)f(x), x + 1, (int)f(x + 1));
            }
        }
      public String getAppletInfo() {
        return "Draws a sin graph.";
      }
    }