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

📄 sdabaseedit.java

📁 很好的UI界面源码..还有自己的输入法,可以更换风格.可以学习和使用
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    fillRect(g, thisWidth - barwidth, barwidth + ppos, barwidth, pheight);                    g.setColor(getBorderColor());                    drawRect(g, thisWidth - barwidth, barwidth + ppos, barwidth, pheight);                    //记录大小                    VSLeft = thisWidth - barwidth;                    VSTop = barwidth + ppos;                    VSWidth = barwidth;                    VSHeight = pheight;                    //画块上的线                    int tpos = VSHeight / 2 + VSTop;                    drawRect(g, VSLeft + 2, tpos, barwidth - 4, 0);                    if (tpos - 2 > VSTop) {                        drawRect(g, VSLeft + 2, tpos - 2, VSWidth - 4, 0);                    }                    if (tpos + 2 < VSTop + VSHeight) {                        drawRect(g, VSLeft + 2, tpos + 2, VSWidth - 4, 0);                    }                    //三角                    g.setColor(getBorderColor());                    fillTriangle(g, thisWidth - barwidth + barwidth / 2, barwidth / 2 - 2,                            thisWidth - barwidth + barwidth / 2 - 4, barwidth / 2 + 2,                            thisWidth - barwidth + barwidth / 2 + 4, barwidth / 2 + 2);                    fillTriangle(g, thisWidth - barwidth + barwidth / 2 - 4, VBarHeight - barwidth + barwidth / 2 - 2,                            thisWidth - barwidth + barwidth / 2 + 4, VBarHeight - barwidth + barwidth / 2 - 2,                            thisWidth - barwidth + barwidth / 2, VBarHeight - barwidth / 2 + 2);                }            }            PaintChilds();        }    }    //获取最大可视行    private int getMaxVisibleLineNum() {        return getVBarHeight() / getFont().getHeight();    }    //对单行处理    private void paintWordWrap(Graphics g, String str, int left) {        int strLength = str.length();        int currentWidth = 0;        int startPoint = 0;        int id = 0;        Font ft = getFont();        for (int i = 0; i < strLength; i++) {            currentWidth += ft.charWidth(str.charAt(i));            id++;            if (currentWidth > maxLineLenght) {                //如果cursorCol在最后,应该换行                if (cursorCol > 0 && cursorCol == id && lineNo == cursorRow) {                    cursorCol = 1;                    cursorRow++;                }                //返回一个字符                i--;                id = 0;                String subStr = str.substring(startPoint, i + 1);                drawString(g, subStr, left, (lineNo - startLine) * getFont().getHeight());                if (lineNo < cursorRow) {                    cursorLineStartPos += subStr.length();                    priorLineLen = subStr.length();                }                if (lineNo == cursorRow) {                    paintCursor(g, 0, subStr);                }                startPoint = i + 1;                currentWidth = 0;                lineNo++;            }        }        String subStr = str.substring(startPoint, strLength);        drawString(g, subStr, left, (lineNo - startLine) * getFont().getHeight());        if (lineNo < cursorRow) {            if (cursorRow < lineNum) {                cursorLineStartPos += subStr.length() + 1;            }            priorLineLen = subStr.length();        }        if (lineNo == cursorRow) {            paintCursor(g, 0, subStr);        }        lineNo++;    }    //按指定字符转换    private String getPassString(String str, char ch) {        String rstr = "";        for (int i = 0; i < str.length(); i++) {            rstr += ch;        }        return rstr;    }    //画光标    private void paintCursor(Graphics g, int left, String lineText) {        if (isFoucsed()) {            cursorLineText = lineText;            int curLeft = 0;            if (lineText.length() > cursorCol) {                curLeft = getFont().stringWidth(lineText.substring(0, cursorCol));            } else {                curLeft = getFont().stringWidth(lineText);                cursorCol = lineText.length();            }            g.setColor(foreColor);            if (isMultiLine()) {                drawLine(g, 2 + curLeft - startLeft, getFont().getHeight() * (cursorRow - startLine),                        2 + curLeft - startLeft, getFont().getHeight() * (cursorRow - startLine + 1));            } else {                drawLine(g, curLeft - startLeft + left, 0, curLeft - startLeft + left, getFont().getHeight());            }        }    }    //获取换行    private int getChangeLinePos(String text) {        int intNpos = text.indexOf('\n');        int intRpos = text.indexOf('\r');        int pos = -1;        if (intNpos > -1 && intRpos > -1) {            if (intNpos > intRpos) {                pos = intRpos;            } else {                pos = intNpos;            }        } else {            if (intNpos > -1) {                pos = intNpos;            }            if (intRpos > -1) {                pos = intRpos;            }        }        return pos;    }    //打字    private void paintString(Graphics g, String text, int left, int top) {        int fontHeight = getFont().getHeight();        g.setColor(getForeColor());        if (!isMultiLine()) {            SetClip(g, 2, 2, width - 4, height - 4);        } else {            if (scrollBars == SDAConsts.srHorizontal) {                SetClip(g, 2, 2, width - 4, height - 4 - barwidth);            }            if (scrollBars == SDAConsts.srVertical) {                SetClip(g, 2, 2, width - 4 - barwidth, height - 4);            }            if (scrollBars == SDAConsts.srBoth) {                SetClip(g, 2, 2, width - 4 - barwidth, height - 4 - barwidth);            }        }        if ((scrollBars == SDAConsts.srVertical) || (scrollBars == SDAConsts.srBoth)) {            maxLineLenght = width - barwidth;        } else {            maxLineLenght = width;        }        cursorLineStartPos = 0;        lineNo = 0;        if (!isMultiLine()) {            //判断密码字符            String str = (passwordChar == 0) ? text : (getPassString(text, passwordChar));            if (textAlign == SDAConsts.alignLeft) {                drawString(g, str, left - startLeft, top);            } else {                drawString(g, str, left, top);            }            paintCursor(g, left, str);        } else {            //如果是空的            if (text.length() == 0) {                paintCursor(g, 0, text);            }            //多行的            if (isWordWrap()) {                //长行自动分行,分行符自动到一行                String str = "";                int pos = 0;                while (getChangeLinePos(text) > -1) {                    pos = getChangeLinePos(text);                    str = text.substring(0, pos);                    String str1 = (passwordChar == 0) ? str : (getPassString(str, passwordChar));                    paintWordWrap(g, str1, left);                    text = text.substring(pos + 1);                }                String str1 = (passwordChar == 0) ? text : (getPassString(text, passwordChar));                paintWordWrap(g, str1, left);                lineNum = lineNo;            } else {                //不自动换行(根据"\n"换行)                String str = "";                lineNo = 0;                maxLineLenght = 0;                int pos = 0;                if (isMultiLine()) {                    while (getChangeLinePos(text) > -1) {                        pos = getChangeLinePos(text);                        str = text.substring(0, pos);                        String str1 = (passwordChar == 0) ? str : (getPassString(str, passwordChar));                        if (maxLineLenght < getFont().stringWidth(str1)) {                            maxLineLenght = getFont().stringWidth(str1);                        }                        if (lineNo < cursorRow) {                            cursorLineStartPos += str1.length() + 1;                        }                        if (lineNo == cursorRow) {                            paintCursor(g, 0, str1);                        }                        drawString(g, str1, left - startLeft, top + fontHeight * (lineNo - startLine));                        text = text.substring(pos + 1);                        lineNo += 1;                    }                }                if (text.length() > 0) {                    String str1 = (passwordChar == 0) ? text : (getPassString(text, passwordChar));                    drawString(g, str1, left - startLeft, top + fontHeight * (lineNo - startLine));                    if (lineNo < cursorRow) {                        cursorLineStartPos += str1.length() + 1;                    }                    if (lineNo == cursorRow) {                        paintCursor(g, 0, str1);                    }                    lineNo += 1;                    if (maxLineLenght < getFont().stringWidth(str1)) {                        maxLineLenght = getFont().stringWidth(str1);                    }                }                lineNum = lineNo;                maxLineLenght += fontHeight / 2;            }        }        lineNum = lineNo;    }    public int getHeight() {        return internalGetHeight();    }    private int internalGetHeight() {        if (!isMultiLine()) {            return super.getFont().getHeight() + 3;        } else {            return super.getHeight();        }    }    public void setHeight(int height) {        internalSetHeight(height);    }    private void internalSetHeight(int height) {        //对于单行不起作用        if (isMultiLine()) {            super.setHeight(height);        } else {            super.setHeight(getFont().getHeight() + 3);        }        internalPaint();    }    public int getBorderStyle() {        return borderStyle;    }    public void setBorderStyle(int borderStyle) {        this.borderStyle = borderStyle;        internalPaint();    }    public boolean isHideSelection() {        return hideSelection;    }    public void setHideSelection(boolean hideSelection) {        this.hideSelection = hideSelection;        internalPaint();    }    public int getMaxLength() {        return maxLength;    }    public void setMaxLength(int maxLength) {        this.maxLength = maxLength;        //内容处理        setText(getText());        doTextChange();        internalPaint();    }    public boolean isMultiLine() {        return multiLine;    }    public void setMultiLine(boolean multiLine) {        this.multiLine = multiLine;        internalPaint();    }    public char getPasswordChar() {        return passwordChar;    }    public void setPasswordChar(char passwordChar) {        this.passwordChar = passwordChar;        repaintControl();    }    public boolean isReadOnly() {        return readOnly;    }    public void setReadOnly(boolean readOnly) {        this.readOnly = readOnly;    }    public int getScrollBars() {        return scrollBars;    }    public void setScrollBars(int scrollBars) {        this.scrollBars = scrollBars;        repaintControl();    }    public int getTextAlign() {        return textAlign;    }    public void setTextAlign(int textAlign) {        this.textAlign = textAlign;        repaintControl();    }    public boolean isWordWrap() {        return wordWrap;    }    public void setWordWrap(boolean wordWrap) {        this.wordWrap = wordWrap;        repaintControl();    }    public int getScrollBarWidth() {        return barwidth;    }    public void setScrollBarWidth(int barwidth) {        this.barwidth = barwidth;        repaintControl();    }    public void setText(String text) {        internalSetText(text);    }    private void internalSetText(String text) {        //判断最大长度        if (text.length() > getMaxLength()) {            text = text.substring(0, getMaxLength());        }        super.setText(text);        repaintControl();    }    public int getBorderColor() {        return borderColor;    }    public void setBorderColor(int borderColor) {        this.borderColor = borderColor;        repaintControl();    }    public int getScrollBarColor() {

⌨️ 快捷键说明

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