⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chatdialogview.java

📁 用jxse开发的一个p2p通讯软件 有聊天 文件共享 视频3大功能
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                                        String mnemonic, boolean toggle, String group, Object callback,                                        String handler) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Begin createAction(String, String, String, boolean, String, Object, String)");            LOG.fine("id        = " + id);            LOG.fine("name      = " + name);            LOG.fine("mnemonic  = " + mnemonic);            LOG.fine("toggle    = " + toggle);            LOG.fine("group     = " + group);            LOG.fine("callback  = " + callback);            LOG.fine("handler   = " + handler);        }        AbstractAction a;        if (callback == null ||                handler == null ||                (handler.trim().length() == 0)) {            a = ActionFactory.createTargetableAction(id, name, mnemonic,                    toggle, group);        } else {            a = ActionFactory.createBoundAction(id, name, mnemonic, toggle,                    group);        }        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("End   createAction(String, String, String, boolean, String, Object, String)");        }        return a;    }    // xxx: don't dispatch empty body ... but we'll loose headers (eg location)    void dispatch() {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Begin dispatch()");        }        setEditor(false);        // xxx: need to dispatch if no content yet includes markup (eg <img ...>)        if (hasBody(this.editor)) {            String s = removeText(this.editor);            this.dialog.dispatch(s);            setEditor(false, true);            addHistory(s);        }        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("End   dispatch()");        }    }    private void addHistory(String s) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Begin addHistory(String)");        }        if (this.history == null) {            this.history = new ArrayList<String>();        }        this.history.add(0, s);        int i;        while ((i = this.history.size()) > HISTORY_MAX) {            this.history.remove(i - 1);        }        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("End   addHistory(String)");        }    }    private File getDefaultLogFile(File parent) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("In getDefaultLogFile(File)");        }        return new File(parent, DEFAULT_LOG_PREFIX +                this.logFormatter.format(new Date()) + DEFAULT_LOG_SUFFIX);    }    private MyDropTargetListener createDropper() {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Begin createDropper()");        }        MyDropTargetListener dtl = new MyDropTargetListener();        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("End   createDropper()");        }        return dtl;    }    private StyleSheet createStyle() {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Begin createStyle()");        }        StyleSheet ss = null;        Constants c = Constants.getInstance();        String style = c.get(Constants.STYLE_RESOURCES, null);        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Constants.STYLE_RESOURCES = " + Constants.STYLE_RESOURCES);            LOG.fine("StyleSheet = " + style);        }        if (style != null &&                style.trim().length() > 0) {            ss = new StyleSheet();            ss.importStyleSheet(getClass().getResource(style));        }        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("End   createStyle()");        }        return ss;    }    private Point calculateScrollerPosition() {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Begin calculateScrollerPosition()");        }        JScrollBar vb = this.rendererScroller.getVerticalScrollBar();        BoundedRangeModel m = vb != null ? vb.getModel() : null;        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("End   calculateScrollerPosition()");        }        return (m != null &&                m.getValue() + m.getExtent() < m.getMaximum()) ?                this.rendererScroller.getViewport().getViewPosition() : null;    }    void adjustScroller(Point p) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Begin adjustScroller()");            LOG.fine("In adjustScroller(Point)");        }        if (p != null) {            this.rendererScroller.getViewport().setViewPosition(p);        }        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("End   adjustScroller()");        }    }    private Element getElement(Document d, HTML.Tag t) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("In getElement(Document, HTML.Tag)");        }        return getElement(d != null ?                d.getDefaultRootElement() : null, t);    }    private Element getElement(Element e, HTML.Tag t) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Begin getElement(Element, HTML.Tag)");        }        Element te = null;        if (e != null) {            Element be;            for (int i = 0; i < e.getElementCount() && te == null; i++) {                be = e.getElement(i);                if (be.getName().equals(t.toString())) {                    te = be;                }                if (te == null &&                        !be.isLeaf()) {                    te = getElement(be, t);                }            }        }        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("End   getElement(Element, HTML.Tag)");        }        return te;    }    private boolean hasBody(JXEditorPane editorPane) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Begin hasBody(JXEditorPane)");        }        Element bt = getElement(editorPane.getDocument(), HTML.Tag.BODY);        HTMLDocument d = (HTMLDocument) bt.getDocument();        String t = null;        try {            t = d.getText(0, d.getLength());        } catch (BadLocationException ble) {            if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                LOG.log(Level.SEVERE, "Caught unexpected Exception", ble);            }        }        boolean retVal = t != null && t.trim().length() > 0;        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Editor Pane contains " + t);            LOG.fine("returning " + retVal);            LOG.fine("End   hasBody(JXEditorPane)");        }        return retVal;    }    private String readText(JXEditorPane editorPane) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("In readText(JXEditorPane)");        }        return readText(editorPane, 0, editorPane.getDocument().getLength());    }    private String readText(JXEditorPane editorPane, int start, int end) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Begin readText(JXEditorPane, int, int)");        }        Writer w = new StringWriter();        try {            editorPane.getEditorKit().write(w, editorPane.getDocument(), start, end);        } catch (IOException ioe) {            if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                LOG.log(Level.SEVERE, "Caught unexpected Exception", ioe);            }        } catch (BadLocationException ble) {            if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                LOG.log(Level.SEVERE, "Caught unexpected Exception", ble);            }        }        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("End   readText(JXEditorPane, int, int)");        }        return w.toString();    }    private String setText(JXEditorPane editorPane, String s) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("In setText(JXEditorPane, String)");        }        String t = removeText(editorPane);        insertText(editorPane, s);        return t;    }    void appendText(JXEditorPane editorPane, String s) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("In appendText(JXEditorPane, String)");        }        if (editorPane != null &&                editorPane.getDocument() != null) {            insertText(editorPane, s, editorPane.getDocument().getLength());        }    }    void insertText(JXEditorPane editorPane, String s) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("In appendText(JXEditorPane, String)");        }        insertText(editorPane, s, editorPane.getCaretPosition());    }    private void insertText(JXEditorPane editorPane, String s, int index) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Begin insertText(JXEditorPane, String, int)");            LOG.fine("String = \"" + s + "\"");            LOG.fine("int = \"" + index + "\"");        }        EditorKit ek = editorPane.getEditorKit();        Document d = editorPane.getDocument();        if (d != null &&                s != null &&                s.length() > 0) {            final Point p = calculateScrollerPosition();            boolean isValid = false;            try {                if (ek instanceof HTMLEditorKit) {                    ((HTMLEditorKit) ek).insertHTML((HTMLDocument) d, index, s,                            0, 0, null);                } else if (ek instanceof DefaultEditorKit) {                    ek.read(new StringReader(s), d, index);                }                isValid = true;            } catch (IOException ioe) {                if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                    LOG.log(Level.SEVERE, "Caught unexpected Exception", ioe);                }            } catch (BadLocationException ble) {                if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                    LOG.log(Level.SEVERE, "Caught unexpected Exception", ble);                }            }            if (isValid) {                editorPane.setCaretPosition(Math.min(index + s.length(),                        d.getLength()));                EventQueue.invokeLater(new Runnable() {                    public void run() {                        adjustScroller(p);                    }                });            }            update(editorPane);        }        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("End   insertText(JXEditorPane, String, int)");        }    }    private String removeText(JXEditorPane editorPane) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("In removeText(JXEditorPane)");        }        return removeText(editorPane, 0, editorPane.getDocument().getLength());    }    private String removeText(JXEditorPane editorPane, int start, int end) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -