g.drawString("当前日期"+t.getDate(),40,40 );
g.drawString("当前日期"+t.getTime(),40,80);

解决方案 »

  1.   

    public abstract void drawString(String str,
                                    int x,
                                    int y)
    Draws the text given by the specified string, using this graphics context's current font and color. The baseline of the leftmost character is at position (x, y) in this graphics context's coordinate system. Parameters:
    str - the string to be drawn.
    x - the x coordinate.
    y - the y coordinate.
      

  2.   

    g.drawString("当前日期"+t.getDate(),40,40 );
    g.drawString("当前日期"+t.getTime(),40,80);
    drawString的参数只有3个。
      

  3.   

    public String getDate()
    {
    Calendar t = cal.getInstance();
    return t.get(t.YEAR)+"年"+(t.get(t.MONTH)+1)+"月"+t.get(t.DATE)+"日";

    }
    public String getTime()
    {
    Calendar t = cal.getInstance();
    String s=t.get(t.HOUR)+"小时"+t.get(t.MINUTE)+"分钟"+t.get(t.SECOND)+"秒";
    return s;

    }