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

📄 propertieseditorsyntax.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            return size + 5;        }                public int getScrollableBlockIncrement(Rectangle visibleRect,                                               int orientation,                                               int direction) {            return size + 5;        }                public boolean getScrollableTracksViewportWidth() {            return true;        }                public boolean getScrollableTracksViewportHeight() {            return false;        }            }            class ColorTableModel extends AbstractTableModel {                private Vector syntaxColours;        private String[] columnHeaders = {"Syntax Style",                                          "Colour",                                          "Font Style"};                ColorTableModel() {            syntaxColours = new Vector(SYNTAX_TYPES.length);                        for (int i = 0; i < SYNTAX_TYPES.length; i++) {                addSyntaxColour(                    getTableValueText(i),                    SystemProperties.getColourProperty("user",                         STYLE_COLOUR_PREFIX + SYNTAX_TYPES[i]),                        SystemProperties.getIntProperty("user",                             STYLE_NAME_PREFIX + SYNTAX_TYPES[i]),                    SYNTAX_TYPES[i]);            }                    }                private String getTableValueText(int styleIndex) {                        switch (styleIndex) {                                case 0:                    return "Normal Text";                case 1:                    return "Keywords";                case 2:                    return "Quote string";                case 3:                    return "Single-line comment";                case 4:                    return "Multi-line comment";                case 5:                    return "Number";                case 6:                    return "Operator";                case 7:                    return "Braces";                case 8:                    return "Literal";                case 9:                    return "Braces match";                case 10:                    return "Braces error";                default:                    return "Text";                                }                    }                public int getColumnCount() {            return 3;        }                public int getRowCount() {            return syntaxColours.size();        }                public Object getValueAt(int row, int col) {            SyntaxColour ch = (SyntaxColour)syntaxColours.elementAt(row);                        switch(col) {                case 0:                    return ch.label;                case 1:                    return ch.color;                case 2:                    return ch.style;                default:                    return null;            }        }                public void setValueAt(Object value, int row, int col) {            SyntaxColour ch = (SyntaxColour)syntaxColours.elementAt(row);                        if(col == 1) {                ch.color = (Color)value;            }                        else if (col == 2) {                ch.style = (String)value;                                if (ch.style.equals(PLAIN)) {                    ch.fontStyle = 0;                }                else if (ch.style.equals(BOLD)) {                    ch.fontStyle = 1;                }                else if (ch.style.equals(ITALIC)) {                    ch.fontStyle = 2;                }                            }                        if (col == 1 || col == 2) {                samplePanel.repaint();            }                        fireTableRowsUpdated(row, row);        }                public boolean isCellEditable(int nRow, int nCol) {            if (nCol == 2)                return true;            else                return false;        }                public String getColumnName(int col) {            return columnHeaders[col];        }                public SyntaxColour[] getSyntaxColours() {            return (SyntaxColour[])syntaxColours.toArray(            new SyntaxColour[syntaxColours.size()]);        }                public void save() {                        for(int i = 0; i < syntaxColours.size(); i++) {                SyntaxColour ch = (SyntaxColour)syntaxColours.elementAt(i);                SystemProperties.setColourProperty("user",                         STYLE_COLOUR_PREFIX + ch.property, ch.color);                SystemProperties.setIntProperty("user",                         STYLE_NAME_PREFIX + ch.property, ch.fontStyle);            }                    }                private void addSyntaxColour(String label, Color color, int style, String property) {            syntaxColours.addElement(new SyntaxColour(label, color, style, property));        }            } // ColorTableModel        static class SyntaxColour {        String label;        int fontStyle;        String style;        String property;        Color color;                SyntaxColour(String label, Color color, int fontStyle, String property) {            this.label = label;            this.fontStyle = fontStyle;            this.color = color;            this.property = property;                        switch(fontStyle) {                case 0:                    style = PLAIN;                    break;                case 1:                    style = BOLD;                    break;                case 2:                    style = ITALIC;                    break;            }        }                public boolean isBackgroundPainted() {            return property.indexOf("braces.") != -1;        }                public String toString() {            return label;        }    } // SyntaxColour        static class ColorRenderer extends JLabel                               implements TableCellRenderer {                public ColorRenderer() {            setOpaque(true);        }                public Component getTableCellRendererComponent(JTable table,                                                       Object value,                                                       boolean isSelected,                                                       boolean cellHasFocus,                                                       int row, int col) {            if (isSelected) {                setBackground(table.getSelectionBackground());                setForeground(table.getSelectionForeground());            }	else {                setBackground(table.getBackground());                setForeground(table.getForeground());            }            if (value != null) {                setBackground((Color)value);            }                        return this;        }    } // ColorRenderer        class MouseHandler extends MouseAdapter {        public void mouseClicked(MouseEvent evt) {            int row = table.rowAtPoint(evt.getPoint());            int col = table.columnAtPoint(evt.getPoint());            if (row == -1) {                return;            }            if (col == 1) {                Color color = JColorChooser.showDialog(                                    GUIUtilities.getParentFrame(),                                    "Select Colour",                                    (Color)tableModel.getValueAt(row, 1));                                if(color != null) {                    tableModel.setValueAt(color, row, 1);                }            } else if (col == 2) {                tableModel.setValueAt(tableModel.getValueAt(row, col), row, 2);            } else {                return;            }        }    } // MouseHandler    }

⌨️ 快捷键说明

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