public void paint(Graphics g) {

        if (g == null || iWidth <= 0 || iHeight <= 0) {
            return;
        }

        g.setColor(SystemColor.control);
        g.fillRect(iWidth, iHeight, iSbWidth, iSbHeight);

        if (iImage == null) {
            iImage = createImage(iWidth, iHeight);
            gImage = iImage.getGraphics();

            gImage.setFont(fFont);
        }

        gImage.setColor(Color.white);
        gImage.fillRect(0, 0, iWidth, iHeight);

        int[]    lasty = new int[100];
        String[] root  = new String[100];

        root[0] = "";

        int currentindent = 0;
        int y             = iRowHeight;

        y -= iY;

        boolean closed = false;

        for (int i = 0; i < iRowCount; i++) {
            String[] s      = (String[]) vData.elementAt(i);
            String   key    = s[0];
            String   data   = s[1];
            String   folder = s[2];
            int      ci     = currentindent;

            for (; ci > 0; ci--) {
                if (key.startsWith(root[ci])) {
                    break;
                }
            }

            if (root[ci].length() < key.length()) {
                ci++;
            }

            if (closed && ci > currentindent) {
                continue;
            }

            closed   = folder != null && folder.equals("+");
            root[ci] = key;

            int x = iIndentWidth * ci - iX;

            gImage.setColor(Color.lightGray);
            gImage.drawLine(x, y, x + iIndentWidth, y);
            gImage.drawLine(x, y, x, lasty[ci]);

            lasty[ci + 1] = y;

            int py = y + iRowHeight / 3;
            int px = x + iIndentWidth * 2;

            if (folder != null) {
                lasty[ci + 1] += 4;

                int rgb = Integer.parseInt(s[3]);

                gImage.setColor(rgb == 0 ? Color.white
                                         : new Color(rgb));
                gImage.fillRect(x + iIndentWidth - 3, y - 3, 7, 7);
                gImage.setColor(Color.black);
                gImage.drawRect(x + iIndentWidth - 4, y - 4, 8, 8);
                gImage.drawLine(x + iIndentWidth - 2, y,
                                x + iIndentWidth + 2, y);

                if (folder.equals("+")) {
                    gImage.drawLine(x + iIndentWidth, y - 2,
                                    x + iIndentWidth, y + 2);
                }
            } else {
                px -= iIndentWidth;
            }

            gImage.setColor(Color.black);
            gImage.drawString(data, px, py);

            currentindent = ci;
            y             += iRowHeight;
        }

        g.drawImage(iImage, 0, 0, this);
    }
public void paint ( Graphics g ) { if ( g == null || iWidth <= 0 || iHeight <= 0 ) { return ; } g . setColor ( SystemColor . control ) ; g . fillRect ( iWidth , iHeight , iSbWidth , iSbHeight ) ; if ( iImage == null ) { iImage = createImage ( iWidth , iHeight ) ; gImage = iImage . getGraphics ( ) ; gImage . setFont ( fFont ) ; } gImage . setColor ( Color . white ) ; gImage . fillRect ( 0 , 0 , iWidth , iHeight ) ; int [ ] lasty = new int [ 100 ] ; String [ ] root = new String [ 100 ] ; root [ 0 ] = "" ; int currentindent = 0 ; int y = iRowHeight ; y -= iY ; boolean closed = false ; for ( int i = 0 ; i < iRowCount ; i ++ ) { String [ ] s = ( String [ ] ) vData . elementAt ( i ) ; String key = s [ 0 ] ; String data = s [ 1 ] ; String folder = s [ 2 ] ; int ci = currentindent ; for ( ; ci > 0 ; ci -- ) { if ( key . startsWith ( root [ ci ] ) ) { break ; } } if ( root [ ci ] . length ( ) < key . length ( ) ) { ci ++ ; } if ( closed && ci > currentindent ) { continue ; } closed = folder != null && folder . equals ( "+" ) ; root [ ci ] = key ; int x = iIndentWidth * ci - iX ; gImage . setColor ( Color . lightGray ) ; gImage . drawLine ( x , y , x + iIndentWidth , y ) ; gImage . drawLine ( x , y , x , lasty [ ci ] ) ; lasty [ ci + 1 ] = y ; int py = y + iRowHeight / 3 ; int px = x + iIndentWidth * 2 ; if ( folder != null ) { lasty [ ci + 1 ] += 4 ; int rgb = Integer . parseInt ( s [ 3 ] ) ; gImage . setColor ( rgb == 0 ? Color . white : new Color ( rgb ) ) ; gImage . fillRect ( x + iIndentWidth - 3 , y - 3 , 7 , 7 ) ; gImage . setColor ( Color . black ) ; gImage . drawRect ( x + iIndentWidth - 4 , y - 4 , 8 , 8 ) ; gImage . drawLine ( x + iIndentWidth - 2 , y , x + iIndentWidth + 2 , y ) ; if ( folder . equals ( "+" ) ) { gImage . drawLine ( x + iIndentWidth , y - 2 , x + iIndentWidth , y + 2 ) ; } } else { px -= iIndentWidth ; } gImage . setColor ( Color . black ) ; gImage . drawString ( data , px , py ) ; currentindent = ci ; y += iRowHeight ; } g . drawImage ( iImage , 0 , 0 , this ) ; }
Method declaration


@param g