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

📄 sdatabcontrol.java

📁 很好的UI界面源码..还有自己的输入法,可以更换风格.可以学习和使用
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                        }                        if (glyphAlignType == SDAConsts.blGlyphBottom) {                            drawImage(g, image, buttonPos + (button.getButtonWidth() - image.getWidth()) / 2 + 1,                                    offset + (button.getButtonHeight() - image.getHeight() - fontHeight) / 2 + fontHeight + 1, 0);                            g.setColor(foreColor);                            drawString(g, caption, buttonPos + (button.getButtonWidth() - ft.stringWidth(caption)) / 2 + 1,                                    offset + (button.getButtonHeight() - image.getHeight() - fontHeight) / 2 + 1);                        }                        if (glyphAlignType == SDAConsts.blGlyphLeft) {                            drawImage(g, image, buttonPos + (button.getButtonWidth() - image.getWidth() - ft.stringWidth(caption) - 2) / 2 + 1,                                    offset + (button.getButtonHeight() - image.getHeight()) / 2 + 1, 0);                            g.setColor(foreColor);                            drawString(g, caption, buttonPos + (button.getButtonWidth() - ft.stringWidth(caption) - image.getWidth() - 2) / 2 + image.getWidth() + 3,                                    offset + (button.getButtonHeight() - fontHeight) / 2 + 1);                        }                        if (glyphAlignType == SDAConsts.blGlyphRight) {                            drawImage(g, image, buttonPos + (button.getButtonWidth() - image.getWidth() - ft.stringWidth(caption) - 2) / 2 + ft.stringWidth(caption) + 3,                                    offset + (button.getButtonHeight() - image.getHeight()) / 2 + 1, 0);                            g.setColor(foreColor);                            drawString(g, caption, buttonPos + (button.getButtonWidth() - ft.stringWidth(caption) - image.getWidth() - 2) / 2 + 1,                                    offset + (button.getButtonHeight() - fontHeight) / 2 + 1);                        }                    } else {                        drawImage(g, image, buttonPos + (button.getButtonWidth() - image.getWidth()) / 2 + 1,                                offset + (button.getButtonHeight() - image.getHeight()) / 2 + 1, 0);                    }                } else {                    if (showCaption) {                        g.setColor(foreColor);                        drawString(g, button.getCaption(), buttonPos + (button.getButtonWidth() - ft.stringWidth(button.getCaption())) / 2 + 1,                                offset + (button.getButtonHeight() - fontHeight) / 2 + 1);                    }                }                SetClip(g);                buttonPos += button.getButtonWidth();                if (buttonPos + 2 * scrollButtonSize < width) {                    endButtonPos = i;                }            }            if (buttonPos + 2 * scrollButtonSize > width) {                canScroll = true;            } else {                canScroll = false;            }        }        if (buttonAlignType == SDAConsts.ktVertical) {            //线            g.setColor(borderColor);            int linePos = buttonPosition == SDAConsts.tabButtonsLeft ? SelectbuttonSize : offset;            drawLine(g, linePos, 0, linePos, getHeight());            for (int i = StartButtonPos; i < controlList.size(); i++) {                button = (SDATabSheet) controlList.elementAt(i);                caption = button.getCaption();                g.setColor(borderColor);                drawRect(g, offset, buttonPos, button.getButtonWidth(), button.getButtonHeight());                //SetClip(g, offset, buttonPos, button.getButtonWidth() + 1, button.getButtonHeight());                image = button.getImage();                if (button.equals(curSheet)) {                    g.setColor(button.backColor);                    fillRect(g, offset + (buttonPosition == SDAConsts.tabButtonsLeft ? 1 : 0), buttonPos + 1,                            button.getButtonWidth() + (buttonPosition == SDAConsts.tabButtonsLeft ? 1 : 0), button.getButtonHeight() - 1);                }                if (image != null) {                    if (showCaption && caption.length() > 0) {                        if (glyphAlignType == SDAConsts.blGlyphTop) {                            drawImage(g, image, offset + (button.getButtonWidth() - image.getWidth()) / 2 + 1,                                    buttonPos + (button.getButtonHeight() - image.getHeight() - fontHeight) / 2 + 1, 0);                            g.setColor(foreColor);                            drawString(g, caption, offset + (button.getButtonWidth() - ft.stringWidth(caption)) / 2 + 1,                                    buttonPos + (button.getButtonHeight() - image.getHeight() - fontHeight) / 2 + image.getHeight() + 1);                        }                        if (glyphAlignType == SDAConsts.blGlyphBottom) {                            drawImage(g, image, offset + (button.getButtonWidth() - image.getWidth()) / 2 + 1,                                    buttonPos + (button.getButtonHeight() - image.getHeight() - fontHeight) / 2 + fontHeight + 1, 0);                            g.setColor(foreColor);                            drawString(g, caption, offset + (button.getButtonWidth() - ft.stringWidth(caption)) / 2 + 1,                                    buttonPos + (button.getButtonHeight() - image.getHeight() - fontHeight) / 2 + 1);                        }                        if (glyphAlignType == SDAConsts.blGlyphLeft) {                            drawImage(g, image, offset + (button.getButtonWidth() - image.getWidth() - ft.stringWidth(caption) - 2) / 2 + 1,                                    buttonPos + (button.getButtonHeight() - image.getHeight()) / 2 + 1, 0);                            g.setColor(foreColor);                            drawString(g, caption, offset + (button.getButtonWidth() - ft.stringWidth(caption) - image.getWidth() - 2) / 2 + image.getWidth() + 3,                                    buttonPos + (button.getButtonHeight() - fontHeight) / 2 + 1);                        }                        if (glyphAlignType == SDAConsts.blGlyphRight) {                            drawImage(g, image, offset + (button.getButtonWidth() - image.getWidth() - ft.stringWidth(caption) - 2) / 2 + ft.stringWidth(caption) + 3,                                    buttonPos + (button.getButtonHeight() - image.getHeight()) / 2 + 1, 0);                            g.setColor(foreColor);                            drawString(g, caption, offset + (button.getButtonWidth() - ft.stringWidth(caption) - image.getWidth() - 2) / 2 + 1,                                    buttonPos + (button.getButtonHeight() - fontHeight) / 2 + 1);                        }                    } else {                        drawImage(g, image, offset + (button.getButtonWidth() - image.getWidth()) / 2 + 1,                                buttonPos + (button.getButtonHeight() - image.getHeight()) / 2 + 1, 0);                    }                } else {                    if (showCaption) {                        g.setColor(foreColor);                        //打字                        drawString(g, String.valueOf(caption), offset + (button.getButtonWidth() - ft.stringWidth(caption)) / 2 + 1,                                buttonPos + 2);                    }                }                SetClip(g);                buttonPos += button.getButtonHeight();                if (buttonPos + 2 * scrollButtonSize < height) {                    endButtonPos = i;                }            }            if (buttonPos + 2 * scrollButtonSize > height) {                canScroll = true;            } else {                canScroll = false;            }        }    }    //画滚动按钮    private void paintScrollButton(Graphics g) {        if (buttonAlignType == SDAConsts.ktHorizontal) {            //水平的按钮放右边            if (buttonsLen > width) {                g.setColor(scrollButtonColor);                fillRect(g, width - scrollButtonSize * 2, offset, 2 * scrollButtonSize, scrollButtonSize);                g.setColor(borderColor);                drawRect(g, width - scrollButtonSize * 2, offset, 2 * scrollButtonSize, scrollButtonSize);                drawRect(g, width - scrollButtonSize * 2, offset, scrollButtonSize, scrollButtonSize);                //箭头                fillTriangle(g, width - scrollButtonSize * 2 + scrollButtonSize / 2 - 2, offset + scrollButtonSize / 2,                        width - scrollButtonSize * 2 + scrollButtonSize / 2 + 2, offset + scrollButtonSize / 2 - 4,                        width - scrollButtonSize * 2 + scrollButtonSize / 2 + 2, offset + scrollButtonSize / 2 + 4);                fillTriangle(g, width - scrollButtonSize + scrollButtonSize / 2 - 2, offset + scrollButtonSize / 2 - 4,                        width - scrollButtonSize + scrollButtonSize / 2 - 2, offset + scrollButtonSize / 2 + 4,                        width - scrollButtonSize + scrollButtonSize / 2 + 2, offset + scrollButtonSize / 2);            }        }        if (buttonAlignType == SDAConsts.ktVertical) {            //垂直的按钮放下边            if (buttonsLen > height) {                g.setColor(scrollButtonColor);                fillRect(g, offset + SelectbuttonSize - scrollButtonSize, height - scrollButtonSize * 2, scrollButtonSize, 2 * scrollButtonSize);                g.setColor(borderColor);                drawRect(g, offset + SelectbuttonSize - scrollButtonSize, height - scrollButtonSize * 2, scrollButtonSize, 2 * scrollButtonSize);                drawRect(g, offset + SelectbuttonSize - scrollButtonSize, height - scrollButtonSize * 2, scrollButtonSize, scrollButtonSize);                //箭头                fillTriangle(g, offset + SelectbuttonSize - scrollButtonSize + scrollButtonSize / 2, height - scrollButtonSize * 2 + scrollButtonSize / 2 - 2,                        offset + SelectbuttonSize - scrollButtonSize + scrollButtonSize / 2 - 4, height - scrollButtonSize * 2 + scrollButtonSize / 2 + 2,                        offset + SelectbuttonSize - scrollButtonSize + scrollButtonSize / 2 + 4, height - scrollButtonSize * 2 + scrollButtonSize / 2 + 2);                fillTriangle(g, offset + SelectbuttonSize - scrollButtonSize + scrollButtonSize / 2 - 4, height - scrollButtonSize + scrollButtonSize / 2 - 2,                        offset + SelectbuttonSize - scrollButtonSize + scrollButtonSize / 2 + 4, height - scrollButtonSize + scrollButtonSize / 2 - 2,                        offset + SelectbuttonSize - scrollButtonSize + scrollButtonSize / 2, height - scrollButtonSize + scrollButtonSize / 2 + 2);            }        }    }    //增加button    public void addTabSheet(SDATabSheet sheet) {        if (!controlList.contains(sheet)) {            controlList.addElement(sheet);            AddControl(sheet);            if (curSheet == null) {                curSheet = sheet;            }            repaintControl();        }    }    public SDATabSheet addTabSheet() {        SDATabSheet sheet = new SDATabSheet();        controlList.addElement(sheet);        AddControl(sheet);        if (curSheet == null) {            curSheet = sheet;        }        repaintControl();        return sheet;    }    public SDATabSheet addTabSheet(String caption) {        SDATabSheet sheet = new SDATabSheet();        sheet.setCaption(caption);        controlList.addElement(sheet);        AddControl(sheet);        if (curSheet == null) {            curSheet = sheet;        }        repaintControl();        return sheet;    }    public SDATabSheet addTabSheet(Image image) {        SDATabSheet button = new SDATabSheet();        button.setImage(image);        controlList.addElement(button);        AddControl(button);        if (curSheet == null) {            curSheet = button;        }        repaintControl();        return button;    }    public SDATabSheet addTabSheet(String caption, Image image) {        SDATabSheet button = new SDATabSheet();        button.setCaption(caption);        button.setImage(image);        controlList.addElement(button);        AddControl(button);        if (curSheet == null) {            curSheet = button;        }        repaintControl();        return button;    }    private void setSheetVisible() {        SDATabSheet sheet = null;        for (int i = 0; i < controlList.size(); i++) {            sheet = (SDATabSheet) controlList.elementAt(i);            sheet.setIndex(i);            if (sheet.equals(curSheet)) {                sheet.visible = true;                if (buttonPosition == SDAConsts.tabButtonsLeft) {                    sheet.setLeft(SelectbuttonSize + 1);                    sheet.setTop(1);                    sheet.setWidth(width - SelectbuttonSize - 1);                    sheet.setHeight(height - 1);                }                if (buttonPosition == SDAConsts.tabButtonsRight) {                    sheet.setLeft(1);                    sheet.setTop(1);                    sheet.setWidth(width - SelectbuttonSize - 1);                    sheet.setHeight(height - 1);                }                if (buttonPosition == SDAConsts.tabButtonsTop) {                    sheet.setLeft(1);                    sheet.setTop(SelectbuttonSize + 1);                    sheet.setWidth(width - 1);                    sheet.setHeight(height - SelectbuttonSize - 1);                }                if (buttonPosition == SDAConsts.tabButtonsBottom) {                    sheet.setLeft(1);                    sheet.setTop(1);                    sheet.setWidth(width - 1);                    sheet.setHeight(height - SelectbuttonSize - 1);                }            } else {                sheet.visible = false;            }        }    }    public int getBorderColor() {        return borderColor;    }    public void setBorderColor(int borderColor) {        this.borderColor = borderColor;        repaintControl();    }    public boolean isAutoSizeButton() {        return autoSizeButton;    }    public void setAutoSizeButton(boolean autoSizeButton) {        this.autoSizeButton = autoSizeButton;        repaintControl();    }    public boolean isShowCaption() {        return showCaption;    }    public void setShowCaption(boolean showCaption) {        this.showCaption = showCaption;        repaintControl();    }    public Image getBackImage() {        return backImage;    }    public void setBackImage(Image backImage) {        this.backImage = backImage;

⌨️ 快捷键说明

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