    public void paint(Graphics g) {
        mHeight = 0;
        iHeight = 0;
        if (messagesWidth == 0) {
            messagesWidth = getListWidth();
        }
        beginPaint();
       PopUp.getInstance().init(g, width, height);
        int count = updateLayout();
        setAbsOrg(g, 0, 0);
        g.setColor(ColorTheme.getColor(ColorTheme.LIST_BGND));
        g.fillRect(0, 0, width, height);
        if (mainbar != null) {
            mHeight = mainbar.getVHeight(); 
        }
        if (infobar != null) {
            setInfo();
            iHeight = infobar.getVHeight(); 
        }
        if (paintTop) {
            if (reverse) {
                if (infobar != null) {
                    iHeight = infobar.getVHeight();
                    list_top = iHeight;
                    drawInfoPanel(g);
                }
            } else {
                if (mainbar != null) {
                    list_top = mHeight;
                    drawMainPanel(g);
                }
            }
        }
        if (paintBottom) {
            if (reverse) {
                if (mainbar != null) {
                    list_bottom = mHeight;
                }
            } else {
                list_bottom = iHeight;
            }
        }
        winHeight = height - list_top - list_bottom;
        boolean scroll = (listHeight > winHeight);
        if (count == 0) {
            cursor = (cursor == -1) ? -1 : 0;
            win_top = 0;
        } else if (cursor >= count) {
            cursor = count - 1;
            stickyWindow = true;
        }
        if (updateLayout() > 0 && stickyWindow) {
            fitCursorByTop();
        }
        int itemMaxWidth = (scroll) ? (width - scrollbar.getScrollWidth()) : (width);
        int itemIndex = win_top > 0 ? getElementIndexAt(win_top) : 0;
        int displayedIndex = 0;
        int displayedBottom = list_top;
        int baloon = -1;
        while (itemIndex < count) {
            int itemYpos = itemLayoutY[itemIndex] - win_top;
            if (itemYpos >= winHeight) {
                break;
            }
            VirtualElement el = getItemRef(itemIndex);
            boolean sel = (itemIndex == cursor);
            if (el != null) {
                int lh = el.getVHeight();
                setAbsOrg(g, 0, list_top);
                g.setClip(0, 0, itemMaxWidth, winHeight);
                g.translate(0, itemYpos);
                g.setColor(el.getColorBGnd());
                if (sel) {
                    drawCursor(g, itemMaxWidth, lh);
                    baloon = g.getTranslateY();
                } else {
                    {
                        g.fillRect(0, 0, itemMaxWidth, lh); 
                    }
                }
                g.setColor(el.getColor());
                g.clipRect(0, 0, itemMaxWidth, lh);
                el.drawItem(g, (sel) ? offset : 0, sel);
                displayedBottom = list_top + itemYpos + lh;
            }
            itemIndex++;
        } 
        int clrH = height - displayedBottom;
        if (clrH > 0
                ) {
            setAbsOrg(g, 0, displayedBottom);
            g.setClip(0, 0, itemMaxWidth, clrH);
            g.setColor(ColorTheme.getColor(ColorTheme.LIST_BGND));
            g.fillRect(0, 0, itemMaxWidth, clrH);
        }
        if (scroll) {
            setAbsOrg(g, 0, list_top);
            g.setClip(0, 0, width, winHeight);
            scrollbar.setPostion(win_top);
            scrollbar.setSize(listHeight);
            scrollbar.setWindowSize(winHeight);
            scrollbar.draw(g);
        } else {
            scrollbar.setSize(0);
        }
        setAbsClip(g, width, height);
if (paintBottom) {
            if (reverse) {
        if (mainbar != null) {
            setAbsOrg(g, 0, height - mHeight);
            drawMainPanel(g);
            CommandsPointer.init(width, height, mHeight);
        }
    } else {
        if (infobar != null) {
            setAbsOrg(g, 0, height - iHeight);
            drawInfoPanel(g);
            CommandsPointer.init(width, height, iHeight);
        }
    }
            setAbsClip(g, width, height);
            if (sd.roster.messageCount > 0) {
                drawEnvelop(g);
            }
            if (System.currentTimeMillis() - sd.getTrafficIn() < 2000) {
                drawTraffic(g, false);
            }
            if (System.currentTimeMillis() - sd.getTrafficOut() < 2000) {
                drawTraffic(g, true);
            }
        }
        setAbsClip(g, width, height);
        drawPopUp(g);
        reconnectWindow.getInstance().draw(g, width, height);
    }

    public synchronized void paint(Graphics g) {
        mHeight = 0;
        iHeight = 0;
        if (messagesWidth == 0) {
            messagesWidth = getListWidth();
        }
        beginPaint();
       PopUp.getInstance().init(g, width, height);
        int count = updateLayout();
        setAbsOrg(g, 0, 0);
        g.setColor(ColorTheme.getColor(ColorTheme.LIST_BGND));
        g.fillRect(0, 0, width, height);
        if (mainbar != null) {
            mHeight = mainbar.getVHeight(); 
        }
        if (infobar != null) {
            setInfo();
            iHeight = infobar.getVHeight(); 
        }
        if (paintTop) {
            if (reverse) {
                if (infobar != null) {
                    iHeight = infobar.getVHeight();
                    list_top = iHeight;
                    drawInfoPanel(g);
                }
            } else {
                if (mainbar != null) {
                    list_top = mHeight;
                    drawMainPanel(g);
                }
            }
        }
        if (paintBottom) {
            if (reverse) {
                if (mainbar != null) {
                    list_bottom = mHeight;
                }
            } else {
                list_bottom = iHeight;
            }
        }
        winHeight = height - list_top - list_bottom;
        boolean scroll = (listHeight > winHeight);
        if (count == 0) {
            cursor = (cursor == -1) ? -1 : 0;
            win_top = 0;
        } else if (cursor >= count) {
            cursor = count - 1;
            stickyWindow = true;
        }
        if (updateLayout() > 0 && stickyWindow) {
            fitCursorByTop();
        }
        int itemMaxWidth = (scroll) ? (width - scrollbar.getScrollWidth()) : (width);
        int itemIndex = win_top > 0 ? getElementIndexAt(win_top) : 0;
        int displayedIndex = 0;
        int displayedBottom = list_top;
        int baloon = -1;
        while (itemIndex < itemLayoutY.length) {
            int itemYpos = itemLayoutY[itemIndex] - win_top;
            if (itemYpos >= winHeight) {
                break;
            }
            VirtualElement el = getItemRef(itemIndex);
            boolean sel = (itemIndex == cursor);
            if (el != null) {
                int lh = el.getVHeight();
                setAbsOrg(g, 0, list_top);
                g.setClip(0, 0, itemMaxWidth, winHeight);
                g.translate(0, itemYpos);
                g.setColor(el.getColorBGnd());
                if (sel) {
                    drawCursor(g, itemMaxWidth, lh);
                    baloon = g.getTranslateY();
                } else {
                    {
                        g.fillRect(0, 0, itemMaxWidth, lh); 
                    }
                }
                g.setColor(el.getColor());
                g.clipRect(0, 0, itemMaxWidth, lh);
                el.drawItem(g, (sel) ? offset : 0, sel);
                displayedBottom = list_top + itemYpos + lh;
            }
            itemIndex++;
        } 
        int clrH = height - displayedBottom;
        if (clrH > 0
                ) {
            setAbsOrg(g, 0, displayedBottom);
            g.setClip(0, 0, itemMaxWidth, clrH);
            g.setColor(ColorTheme.getColor(ColorTheme.LIST_BGND));
            g.fillRect(0, 0, itemMaxWidth, clrH);
        }
        if (scroll) {
            setAbsOrg(g, 0, list_top);
            g.setClip(0, 0, width, winHeight);
            scrollbar.setPostion(win_top);
            scrollbar.setSize(listHeight);
            scrollbar.setWindowSize(winHeight);
            scrollbar.draw(g);
        } else {
            scrollbar.setSize(0);
        }
        setAbsClip(g, width, height);
if (paintBottom) {
            if (reverse) {
        if (mainbar != null) {
            setAbsOrg(g, 0, height - mHeight);
            drawMainPanel(g);
            CommandsPointer.init(width, height, mHeight);
        }
    } else {
        if (infobar != null) {
            setAbsOrg(g, 0, height - iHeight);
            drawInfoPanel(g);
            CommandsPointer.init(width, height, iHeight);
        }
    }
            setAbsClip(g, width, height);
            if (sd.roster.messageCount > 0) {
                drawEnvelop(g);
            }
            if (System.currentTimeMillis() - sd.getTrafficIn() < 2000) {
                drawTraffic(g, false);
            }
            if (System.currentTimeMillis() - sd.getTrafficOut() < 2000) {
                drawTraffic(g, true);
            }
        }
        setAbsClip(g, width, height);
        drawPopUp(g);
        reconnectWindow.getInstance().draw(g, width, height);
    }
