是不是Jclass 不能 用来 做报表啊?那有做 报表的 工具吗?自己做也可以,但是还请提供一下相关的类.我对这不熟.

解决方案 »

  1.   

    我看了一下,好像可以用jclass.table.JCTable但各位有没有类似的源码让我看看.import jclass.table.JCTable;
    import jclass.table.JCTblEnum;
    import jclass.table.JCValidateCellEvent;
    import jclass.table.JCValidateCellListener;
    import jclass.contrib.ContribFrame;
    import java.awt.*;public class ScoreBoard extends jclass.contrib.ContribApplet
    implements JCValidateCellListener{ static final int NUMROWS = 2;                  // 峴悢
    static final int NUMCOLUMNS = 10;              // 寘悢
    static final int RESULTCOLUMN = NUMCOLUMNS-1;  // 寢壥僙儖偺寘
    JCTable table; String teams[] = { "Yokohama Baystars", "Software Design" }; // 僠乕儉 public void init() {
    setAppletLayout(new GridLayout(1,1)); table = new JCTable();       // JCTable傪僐儞僗僩儔僋僩
    table.setNumRows(NUMROWS);           // 峴偺僒僀僘
    table.setNumColumns(NUMCOLUMNS);     // 楍偺僒僀僘
    table.setColumnLabels(counterLabel(NUMCOLUMNS)); // 峴儔儀儖偺僙僢僩
    table.setRowLabels(teams);                 // 楍儔儀儖偺僙僢僩
    table.setForeground(JCTblEnum.ALL, JCTblEnum.ALL, // 暥帤偺怓
    Color.white);
    table.setBackground(JCTblEnum.ALL, JCTblEnum.ALL, // 攚宨偺怓
    new Color(0,128,0)); table.setTraversable(JCTblEnum.ALL, RESULTCOLUMN, false); 
    // 寢壥僙儖偺楍偼僞僢僠偱偒側偄傛偆偵偡傞 table.setCharWidth(JCTblEnum.LABEL, 10);    // 僠乕儉柤儔儀儖偺暆
    table.setCharWidth(JCTblEnum.ALLCELLS, 2);  // 僙儖偺暆 table.setDatatype(JCTblEnum.ALLCELLS, JCTblEnum.ALLCELLS,  
    // 僙儖偵int偺擖椡偟偐嫋偝側偄
      JCTblEnum.TYPE_INTEGER);

    table.setValidatePolicy(JCTblEnum.VALIDATE_USER_EDIT); 
    // 儐乕僓掕媊偺ValidatePolicy傪巊梡偡傞
    table.addValidateCellListener(this); // ValidateCell儕僗僫乕偵搊榐 addToApplet(table);
    } String[] counterLabel(int counter){            // 峴儔儀儖嶌惉儊僜僢僪
    String[] ret = new String[counter];
    for(int i=0; i<counter; i++ )
    ret[i] = new String(new Integer(i+1).toString());
    ret[RESULTCOLUMN] = "R"; // 偪傚偭偲墭偄偱偡偑乧
    return ret;
    }

    public void validateCellBegin(JCValidateCellEvent ev) {
    } public void validateCellEnd(JCValidateCellEvent ev) {
    int row = ev.getRow();
    int column = ev.getColumn(); if (ev.getValue() instanceof Integer) {
    Integer in = (Integer)ev.getValue();
    if (in.intValue() < 0)                // 晄摉側悢帤傪嫋偝側偄
    ev.setAllowValueChange(false);
    int point=0;
    for(int i=0; i<RESULTCOLUMN; i++){    // 寢壥僙儖偺抣傪寁嶼
    if(table.getCell(row, i)!=null)
    point+=((Integer)table.getCell(row, i)).intValue();
    }
    table.setCell(ev.getRow(), RESULTCOLUMN, // 寢壥僙儖偵抣傪僙僢僩
      new Integer(point));
    }
    } public static void main(String args[]) {
    ContribFrame frame = new ContribFrame("ScoreBoard");
    ScoreBoard s = new ScoreBoard();
    s.init();

    frame.add(s);
    frame.pack();
    frame.show();
    }
    }