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

📄 ezcelldemo.java

📁 用Java写的报表.功能如下: 0.内建网络打印,网络预览功能! 1.文件操作。包括url 指定的文件。 2.全功能打印支持。包括打印预览。 3.Undo 和 redo。 4.合并单元格。 5.Cel
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    }

    /**
     * DOCUMENT ME!
     */
    private void updateFormatUI() {
        ZCell cell = cellBean.getActiveCell();
        skipCommand = true;

        // update alignment
        int i = 0;
        int a = cell.getHorzAlign();

        if (a == ZBase.XCENTER) {
            i = FORMAT_ALIGN_X_CENTER;
        } else if (a == ZBase.LEFT) {
            i = FORMAT_ALIGN_LEFT;
        } else {
            i = FORMAT_ALIGN_RIGHT;
        }

        ahs[i].setSelected(true);
        a = cell.getVertAlign();

        if (a == ZBase.YCENTER) {
            i = FORMAT_ALIGN_Y_CENTER;
        } else if (a == ZBase.TOP) {
            i = FORMAT_ALIGN_TOP;
        } else {
            i = FORMAT_ALIGN_BOTTOM;
        }

        ahs[i].setSelected(true);

        ahs[FORMAT_WORD_WRAP].setSelected(cell.isWordWrap());


        // merge ui
        ahs[FORMAT_MERGE].setSelected(cell.isParent());

        // text and background color
        ZBrush b = cell.getTextBrush();

        if ((b != null) && b instanceof ZColorBrush) {
            ((JComboBox) ahs[FORMAT_TEXT_COLOR].getValue("BUTTON")).setSelectedItem(
                    ((ZColorBrush) b).getColor());
        }

        b = cell.getBackBrush();

        if ((b != null) && b instanceof ZColorBrush) {
            ((JComboBox) ahs[FORMAT_BACK_COLOR].getValue("BUTTON")).setSelectedItem(
                    ((ZColorBrush) b).getColor());
        }

        // font
        ZFont font = cell.getFont();

        if (font != null) {
            ((JComboBox) ahs[FORMAT_FONT_NAME].getValue("BUTTON")).setSelectedItem(
                    font.getName());
            ((JComboBox) ahs[FORMAT_FONT_SIZE].getValue("BUTTON")).setSelectedItem(
                    String.valueOf(font.getSize()));
            ahs[FORMAT_FONT_BOLD].setSelected(font.isBold());
            ahs[FORMAT_FONT_ITALIC].setSelected(font.isItalic());
            ahs[FORMAT_FONT_OUTLINE].setSelected(font.isOutline());
        }

        // number format
        String format = cell.getFormat();

        if ((format == null) || format.equals("")) {
            ((JComboBox) ahs[FORMAT_NUMBER_FORMAT].getValue("BUTTON")).setSelectedIndex(0);
        } else {
            ((JComboBox) ahs[FORMAT_NUMBER_FORMAT].getValue("BUTTON")).setSelectedItem(
                    format);
        }

        skipCommand = false;
    }

    /**
     * DOCUMENT ME!
     */
    private void updateUI() {
        // 更改undo,redo 工具栏按钮及菜单设置
        updateUndoUI();


        // 更改与格式相关的工具栏按钮及菜单设置
        updateFormatUI();


        // 更改与格视图相关的工具栏按钮及菜单设置
        updateViewUI();
    }

    /**
     * DOCUMENT ME!
     */
    private void updateUndoUI() {
        skipCommand = true;
        ahs[EDIT_UNDO].setEnabled(cellBean.canUndo());
        ahs[EDIT_REDO].setEnabled(cellBean.canRedo());
        skipCommand = false;
    }

    /**
     * DOCUMENT ME!
     */
    private void updateViewUI() {
        skipCommand = true;

        // zoom menu and button
        float scale = cellBean.getScale();
        int index = 0;

        if (scale == 2.0f) {
            index = VIEW_ZOOM_TO_200;
        } else if (scale == 1.0f) {
            index = VIEW_ZOOM_TO_100;
        } else if (scale == .75f) {
            index = VIEW_ZOOM_TO_75;
        } else if (scale == .50f) {
            index = VIEW_ZOOM_TO_50;
        } else if (scale == .25f) {
            index = VIEW_ZOOM_TO_25;
        }

        ((JRadioButtonMenuItem) ahs[index].getValue("MENU")).setSelected(true);

        int i = (int) (scale * 100);
        ((JComboBox) ahs[VIEW_ZOOM_TO].getValue("BUTTON")).setSelectedItem(i + "%");

        // view page button and menu
        boolean selected = cellBean.isPageViewing();
        ahs[VIEW_PAGE].setSelected(selected);
        this.setTitle("ZCell V1.0[" + cellBean.getTitle() + "]");
        skipCommand = false;
    }

    // 命令处理器类,用于将菜单及按钮命令转化为相应的对EZCell JavaBean的调用
    // 每个命令,对应一个处理器类实列。
    class AH extends AbstractAction {
        AH(int actionIndex, String description, String icon, KeyStroke ak, int ui) {
            super(description);
            putValue(AbstractAction.ACTION_COMMAND_KEY, String.valueOf(actionIndex));

            if (ak != null) {
                putValue(AbstractAction.ACCELERATOR_KEY, ak);
            }

            if ((icon != null) && !icon.equals("")) {
                putValue(AbstractAction.SMALL_ICON, new ImageIcon(getClass().getResource(icon)));
            } else {
                putValue(AbstractAction.SMALL_ICON, ei);
            }

            switch (ui & (MENU | MENUITEM | CHECKBOXMENU | RADIOMENU)) {
            case MENU:
                putValue("MENU", new JMenu(this));

                break;

            case MENUITEM:

                JMenuItem m = new JMenuItem(this);
                m.setActionCommand(
                        (String) this.getValue(AbstractAction.ACTION_COMMAND_KEY));
                putValue("MENU", m);

                break;

            case CHECKBOXMENU:

                JCheckBoxMenuItem ch = new JCheckBoxMenuItem(description);
                ch.addActionListener(this);
                ch.setActionCommand(
                        (String) this.getValue(AbstractAction.ACTION_COMMAND_KEY));
                ch.setSelected((ui & SELECTED) != 0);
                putValue("MENU", ch);

                break;

            case RADIOMENU:

                JRadioButtonMenuItem ra = new JRadioButtonMenuItem(description);
                ra.addActionListener(this);
                ra.setActionCommand(
                        (String) this.getValue(AbstractAction.ACTION_COMMAND_KEY));
                ra.setSelected((ui & SELECTED) != 0);
                putValue("MENU", ra);

                break;
            }

            if ((ui & MENU) != 0) {
            }

            if ((ui & BUTTON) != 0) {
                JButton button = new SmallButton(this);
                button.setActionCommand(
                        (String) this.getValue(AbstractAction.ACTION_COMMAND_KEY));
                button.setToolTipText(description);
                putValue("BUTTON", button);
            } else if ((ui & TOGGLEBUTTON) != 0) {
                JToggleButton toggleButton = new JToggleButton(
                                                     (Icon) this.getValue(
                                                             AbstractAction.SMALL_ICON));
                toggleButton.addActionListener(this);
                toggleButton.setActionCommand(
                        (String) this.getValue(AbstractAction.ACTION_COMMAND_KEY));
                toggleButton.setToolTipText(description);
                toggleButton.setSelected((ui & SELECTED) != 0);
                toggleButton.setPressedIcon(
                        (Icon) this.getValue(AbstractAction.SMALL_ICON));
                toggleButton.setMaximumSize(new Dimension(25, 25));
                toggleButton.getModel().setPressed(true);
                putValue("BUTTON", toggleButton);
            }
        }

        // 取得处理器的工具拦组件,可能是按钮,也可能是选择框(如字体大小选择框),
        //也可能什么也没有(如"退出"命令处理器就有菜单项,但没有工具栏按钮)
        public AbstractButton getButton() {
            return (AbstractButton) getValue("BUTTON");
        }

        // 使该处理器的工具栏或菜单项可用
        public void setEnabled(boolean value) {
            Object o = getValue("BUTTON");

            if ((o != null) && o instanceof Component) {
                ((Component) o).setEnabled(value);
            }

            o = getValue("MENU");

            if ((o != null) && o instanceof Component) {
                ((Component) o).setEnabled(value);
            }
        }

        // 取得处理器菜单项
        public JMenuItem getMenu() {
            return (JMenuItem) getValue("MENU");
        }

        // 设置处理器的工具栏或菜单项是否被选
        public void setSelected(boolean value) {
            Object o = getValue("BUTTON");

            if ((o != null) && o instanceof AbstractButton) {
                ((AbstractButton) o).setSelected(value);
            }

            o = getValue("MENU");

            if ((o != null) && o instanceof AbstractButton) {
                ((AbstractButton) o).setSelected(value);
            }
        }

        // 处理器消息,通知菜单或按钮已经被点击
        public void actionPerformed(ActionEvent e) {
            // 如果命令由移动单元格引起,则无须调用组件
            if (skipCommand) {
                return;
            }

            switch (Integer.parseInt(e.getActionCommand())) {
            case FILE_NEW:
                onFileNew();

                break;

            case FILE_OPEN:
                onFileOpen();

                break;

            case FILE_SAVE:
                onFileSave();

                break;

            case FILE_SAVEAS:
                onFileSaveAs();

                break;

            case FILE_PRINT:
                onFilePrint();

                break;

            case FILE_PRRINTSETUP:
                onFilePrintSetup();

                break;

            case FILE_PRINTPREVIEW:
                onFilePrintPreview();

                break;

            case FILE_EXPORT_AS_POSTSCRIPT:
                onFileExportAsPostscript();

                break;

            case FILE_EXIT:
                onFileExit();

                break;

            case EDIT_UNDO:
                onEditUndo();

                break;

            case EDIT_REDO:
                onEditRedo();

                break;

            case EDIT_COPY:
                onEditCopy();

                break;

            case EDIT_CUT:
                onEditCut();

                break;

            case EDIT_PASTE:
                onEditPaste();

                break;

            case EDIT_PASTE_WITH_FORMAT:
                onEditPasteWithFormat();

                break;

            case EDIT_CLEAR:
                onEditClear();

                break;

            case EDIT_CLEAR_WITH_FORMAT:
                onEditClearWithFormat();

                break;

            case EDIT_CHECK_SPELL:
                onEditCheckSpell();

                break;

            case EDIT_DELETE_ROW:
                onEditDeleteRow();

                break;

            case EDIT_INSERT_ROW:
                onEditInsertRow();

                break;

            case EDIT_DELETE_COL:
                onEditDeleteCol();

                break;

            case EDIT_INSERT_COL:
                onEditInsertCol();

                break;

            case EDIT_DELETE_SHEET:
                onEditDeleteSheet();

                break;

            case EDIT_INSERT_SHEET:
                onEditInsertSheet();

                break;

            case EDIT_SHEET_PROPERTY:
  

⌨️ 快捷键说明

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