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

📄 sdainputpanel.java

📁 很好的UI界面源码..还有自己的输入法,可以更换风格.可以学习和使用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    selectedChar = Chars4[i];                } else {                    selectedChar = Chars2[i];                }            } else {                g.setColor(foreColor);            }            drawString(g, String.valueOf(Chars2[i]), i * width / 13 + (width / 13 - ft.charWidth(Chars2[i])) / 2, curHeight + fontHeight);            g.setColor(foreColor);            drawLine(g, i * width / 13, curHeight + fontHeight, i * width / 13, curHeight + 2 * fontHeight);        }        curHeight += 2 * fontHeight;    }//拼音采用小写字母//输入法选择    private void paintInputMethodSelect(Graphics g) {        g.setColor(borderColor);        int fontHeight = getFont().getHeight();        Font ft = getFont();        drawRect(g, 0, curHeight, width - 1, fontHeight);        //画具体(A,a,1,,.,#,PY,全)        int[] rightPos = new int[6];        for (int i = 1; i <                7; i++) {            drawLine(g, i * width / 7, curHeight, i * width / 7, curHeight + fontHeight);            rightPos[i - 1] = i * width / 7;        }        drawString(g, "ABC", (width / 7 - ft.stringWidth("ABC")) / 2, curHeight);        drawString(g, "abc", width / 7 + (width / 7 - ft.stringWidth("abc")) / 2, curHeight);        drawString(g, "123", 2 * width / 7 + (width / 7 - ft.stringWidth("123")) / 2, curHeight);        drawString(g, ",。", 3 * width / 7 + (width / 7 - ft.stringWidth(",。")) / 2, curHeight);        drawString(g, "※", 4 * width / 7 + (width / 7 - ft.stringWidth("※")) / 2, curHeight);        drawString(g, "中", 5 * width / 7 + (width / 7 - ft.stringWidth("中")) / 2, curHeight);        drawString(g, "全", 6 * width / 7 + (width / 7 - ft.stringWidth("全")) / 2, curHeight);        //画被选中的        switch (ImeType) {            case imUpperCase:                g.setColor(selectedBackColor);                fillRect(g, 1, curHeight + 1, rightPos[0] - 1, fontHeight - 2);                g.setColor(selectedForeColor);                drawString(g, "ABC", (width / 7 - ft.stringWidth("ABC")) / 2, curHeight);                break;            case imLowerCase:                g.setColor(selectedBackColor);                fillRect(g, width / 7 + 1, curHeight + 1, rightPos[1] - width / 7 - 1, fontHeight - 2);                g.setColor(selectedForeColor);                drawString(g, "abc", width / 7 + (width / 7 - ft.stringWidth("abc")) / 2, curHeight);                break;            case imDigit:                g.setColor(selectedBackColor);                fillRect(g, 2 * width / 7 + 1, curHeight + 1, rightPos[2] - 2 * width / 7 - 1, fontHeight - 2);                g.setColor(selectedForeColor);                drawString(g, "123", 2 * width / 7 + (width / 7 - ft.stringWidth("123")) / 2, curHeight);                break;            case imPoint:                g.setColor(selectedBackColor);                fillRect(g, 3 * width / 7 + 1, curHeight + 1, rightPos[3] - 3 * width / 7 - 1, fontHeight - 2);                g.setColor(selectedForeColor);                drawString(g, ",。", 3 * width / 7 + (width / 7 - ft.stringWidth(",。")) / 2, curHeight);                break;            case imSymbol:                g.setColor(selectedBackColor);                fillRect(g, 4 * width / 7 + 1, curHeight + 1, rightPos[4] - 4 * width / 7 - 1, fontHeight - 2);                g.setColor(selectedForeColor);                drawString(g, "※", 4 * width / 7 + (width / 7 - ft.stringWidth("※")) / 2, curHeight);                break;            case imPinYin:                g.setColor(selectedBackColor);                fillRect(g, 5 * width / 7 + 1, curHeight + 1, rightPos[5] - 5 * width / 7 - 1, fontHeight - 2);                g.setColor(selectedForeColor);                drawString(g, "中", 5 * width / 7 + (width / 7 - ft.stringWidth("中")) / 2, curHeight);                break;        }//全角        if (SBCCase) {            g.setColor(selectedBackColor);            fillRect(g, 6 * width / 7 + 1, curHeight + 1, width - 6 * width / 7 - 2, fontHeight - 2);            g.setColor(selectedForeColor);            drawString(g, "全", 6 * width / 7 + (width / 7 - ft.stringWidth("全")) / 2, curHeight);        }        curHeight += fontHeight;    }//获取选择的内容    public char getSelectedChar() {        return selectedChar;    }    //位置    protected void setCharsPanelPos() {        if (ImeType == imPinYin) {            charsPanel.setSize(2, 6);        } else {            if (numChars != null) {                if (numChars.length * getFont().getHeight() != charsPanel.height) {                    charsPanel.setSize(1, numChars.length);                    form.repaintControl();                }            }        }        charsPanel.getCursorPosInForm();        charsPanel.setLeft(charsPanel.oraX);        charsPanel.setTop(charsPanel.oraY);        if (charsPanel.getWidth() + charsPanel.oraX > form.canvas.getWidth()) {            charsPanel.setLeft(form.canvas.getWidth() - charsPanel.getWidth());        }        if (charsPanel.getHeight() + charsPanel.oraY > form.canvas.getHeight() - charsPanel.getHeight()) {            int atop = charsPanel.oraY - getFont().getHeight() - charsPanel.getHeight();            if (atop >= 0) {                charsPanel.setTop(atop);            } else {                if (charsPanel.oraX > charsPanel.getWidth()) {                    charsPanel.setLeft(charsPanel.oraX - charsPanel.getWidth());                } else {                    charsPanel.setLeft(charsPanel.oraX + 10);                }                charsPanel.setTop(0);            }        }    }//显示输入内容    private void paintInputChars() {        setCharsPanelPos();        charsPanel.paint();    }//点面板改变输入法    private void doPointerReleased(int x, int y) {        int posx = screenXToClient(x);        int posy = screenYToClient(y);        int fontHeight = getFont().getHeight();        int pos = 0;        if (InClientRect(posx, posy, 0, height - fontHeight, width, fontHeight)) {            charXPos = -1;            charYPos = -1;            //根据x位置判断输入法类型            pos = posx * 7 / width;            switch (pos) {                case 0:                    ImeType = imUpperCase;                    break;                case 1:                    ImeType = imLowerCase;                    break;                case 2:                    ImeType = imDigit;                    break;                case 3:                    ImeType = imPoint;                    break;                case 4:                    ImeType = imSymbol;                    break;                case 5:                    ImeType = imPinYin;                    SBCCase = false;                    break;                case 6:                    if (ImeType != imPinYin) {                        SBCCase = !SBCCase;                    }                    break;            }            setInputPanelSize();            charsPanel.visible = false;            inputChars.setLength(0);            numChars = null;            form.repaintControl();        } else if (InClientRect(posx, posy, 0, 0, width, fontHeight)) {            charXPos = posx * 10 / width;            charYPos = 0;            getFuncChar();            inputFuncChar();            paint();        } else {            if (ImeType == imDigit) {                //三行                charXPos = posx * 10 / width;                charYPos = 1;                paintDigit(gg);                inputVisibleChar();            } else {                //四行的                if (ImeType == imUpperCase || ImeType == imLowerCase || ImeType == imPinYin || ImeType == imSymbol) {                    charXPos = posx * 13 / width;                    charYPos = posy / fontHeight;                    if (ImeType == imUpperCase) {                        paintUpperCase(gg);                        inputVisibleChar();                    }                    if (ImeType == imLowerCase) {                        paintLowerCase(gg);                        inputVisibleChar();                    }                    if (ImeType == imSymbol) {                        paintSymbol(gg);                        inputVisibleChar();                    }                    if (ImeType == imPinYin) {                        paintLowerCase(gg);                        if (!SBCCase) {                            inputPinYinChar();                        } else {                            inputVisibleChar();                        }                    }                }                if (ImeType == imPoint) {                    charXPos = posx * 14 / width;                    charYPos = posy / fontHeight;                    paintPoint(gg);                    inputVisibleChar();                }            }            if (charsPanel.visible) {                if (ImeType == imUpperCase || ImeType == imLowerCase) {                    charsPanel.visible = false;                    numChars = null;                    form.repaintControl();                } else {                    paint();                }            } else {                paint();            }        }    }    //根据选择的char输入到焦点组件    public void inputVisibleChar() {        InputInterface control = null;        if (form.focusControl != null) {            if (form.focusControl instanceof InputInterface) {                control = (InputInterface) form.focusControl;                control.InputVisibleChar(selectedChar);            }        }        selectedChar = 0;    }    //拼音输入法处理    protected void inputPinYinChar() {        if (form.focusControl == null || (!(form.focusControl instanceof InputInterface))) {            selectedChar = 0;            return;        }        if (inputChars.length() == 0) {            charsPanel.cursorPos = 0;            charsPanel.isInput = true;            inputChars.append(selectedChar);            charsPanel.cursorPos++;        } else {            inputChars.insert(charsPanel.cursorPos, selectedChar);            charsPanel.cursorPos++;        }        charsPanel.visible = true;        charsPanel.pageNo = 1;    }    protected void inputFuncChar() {        InputInterface control = null;        //判断输入选择框是不是已经显示,显示的话就发向这个选择框        if (charsPanel.isVisible()) {            charsPanel.inputFuncChar(selectedChar);        } else {            if (form.focusControl != null) {                if (form.focusControl instanceof InputInterface) {                    control = (InputInterface) form.focusControl;                    control.InputFuncChar(selectedChar, SBCCase);                    selectedChar = 0;                }            }        }    }    public void setDock(int dock) {        super.setDock(SDAConsts.dsBottom);    }//获取内容数组    public char[] getUpperChars() {        return UpperCaseChars;    }    public char[] getSBCUpperChars() {        return SBCUpperCaseChars;    }    public char[] getLowerChars() {        return LowerCaseChars;    }    public char[] getSBCLowerCaseChars() {        return SBCLowerCaseChars;    }    public char[] getDigitChars() {        return DigitChars;    }    public char[] getSBCDigitChars() {        return SBCDigitChars;    }    public char[] getSymbolChars() {        return SymbolChars;    }    public char[] getSBCSymbolChars() {        return SBCSymbolChars;    }    public char[] getPointChars() {        return PointChars;    }    public char[] getSBCPointChars() {        return SBCPointChars;    }    public boolean isSBCCase() {        return SBCCase;    }    public void setSBCCase(boolean SBCCase) {        this.SBCCase = SBCCase;    }}

⌨️ 快捷键说明

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