亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? javafilter.java

?? java文件注釋過濾器,將文件中的注釋過濾掉.
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
package homework;

/*
 * javaFilter.java
 * one additional file:
 *   MyStyledDocument
 */

import java.awt.*;
import java.awt.event.*;
import java.util.HashMap;

import javax.swing.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.undo.*;
import java.io.*;

public class javaFilter extends JFrame {
    JFileChooser chooser;
    JTextPane textPane;
    AbstractDocument doc;
    String newline = "\n";
    HashMap actions;
    Component curComponet = this.getComponent(0);
    //is changed or not
    boolean changed;
    File file;
    MyStyledDocument cur;
    //undo helpers
    protected UndoAction undoAction;
    protected RedoAction redoAction;
    protected UndoManager undo = new UndoManager();
    DefaultEditorKit a = new DefaultEditorKit();

    public javaFilter() {
        //Create the text pane and configure it.

        changed = false;
        file = null;
        setTitle();
        chooser = new JFileChooser();
        textPane = new JTextPane(cur = new MyStyledDocument());
        textPane.setCaretPosition(0);
        textPane.setMargin(new Insets(5, 5, 5, 5));
        StyledDocument styledDoc = textPane.getStyledDocument();
        if (styledDoc instanceof AbstractDocument) {
            doc = (AbstractDocument) styledDoc;
            doc.setDocumentFilter(new DocumentFilter());
        } else {
            System.err.println(
                    "Text pane's document isn't an AbstractDocument!");
            System.exit( -1);
        }
        JScrollPane scrollPane = new JScrollPane(textPane);
        scrollPane.setPreferredSize(new Dimension(400, 400));

        //Create the status area.
        JPanel statusPane = new JPanel(new GridLayout(1, 1));
        CaretListenerLabel caretListenerLabel =
                new CaretListenerLabel("Caret Status");
        statusPane.add(caretListenerLabel);

        //Add the components.
        getContentPane().add(scrollPane, BorderLayout.CENTER);
        getContentPane().add(statusPane, BorderLayout.PAGE_END);

        //Set up the menu bar.
        createActionTable(textPane);
        JMenu fileMenu = createFileMenu();
        JMenu editMenu = createEditMenu();
        JMenu styleMenu = createStyleMenu();
        JMenu aboutMenu = createAboutMenu();

        JMenuBar mb = new JMenuBar();
        mb.add(fileMenu);
        mb.add(editMenu);
        mb.add(styleMenu);
        mb.add(aboutMenu);
        setJMenuBar(mb);

        //Add some key bindings.
        addBindings();

        //Start watching for undoable edits and caret changes.
        doc.addUndoableEditListener(new MyUndoableEditListener());
        textPane.addCaretListener(caretListenerLabel);
        addWindowListener(new closeAdapter());

    }

    public void setTitle() {
        setTitle("Java Filter      " + file);
    }

    class closeAdapter extends WindowAdapter {
        public void windowClosing(WindowEvent e) {
            if (changed) {
                int ret = JOptionPane.showConfirmDialog(null, "Save File?",
                        "Confirm", JOptionPane.YES_NO_OPTION);
                if (ret == JOptionPane.YES_OPTION) {
                    saveFile();
                    System.exit(0);
                } else if (ret == JOptionPane.NO_OPTION) {
                    System.exit(0);
                }
            } else {
                System.exit(0);
            }
        }

    }


    //This listens for and reports caret movements.
    protected class CaretListenerLabel extends JLabel implements CaretListener {
        public CaretListenerLabel(String label) {
            super(label);
        }

        //Might not be invoked from the event dispatching thread.
        public void caretUpdate(CaretEvent e) {
            changed = true;
            displaySelectionInfo(e.getDot(), e.getMark());
        }

        //This method can be invoked from any thread.  It
        //invokes the setText and modelToView methods, which
        //must run in the event dispatching thread. We use
        //invokeLater to schedule the code for execution
        //in the event dispatching thread.
        protected void displaySelectionInfo(final int dot,
                                            final int mark) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    if (dot == mark) { // no selection
                        try {
                            Rectangle caretCoords = textPane.modelToView(dot);
                            //Convert it to view coordinates.
                            setText("caret: text position: " + dot
                                    + ", view location = ["
                                    + caretCoords.x + ", "
                                    + caretCoords.y + "]"
                                    + newline);
                        } catch (BadLocationException ble) {
                            setText("caret: text position: " + dot + newline);
                        }
                    } else if (dot < mark) {
                        setText("selection from: " + dot
                                + " to " + mark + newline);
                    } else {
                        setText("selection from: " + mark
                                + " to " + dot + newline);
                    }
                }
            });
        }
    }


    //This one listens for edits that can be undone.
    protected class MyUndoableEditListener implements UndoableEditListener {
        public void undoableEditHappened(UndoableEditEvent e) {
            //Remember the edit and update the menus.
            undo.addEdit(e.getEdit());
            undoAction.updateUndoState();
            redoAction.updateRedoState();
        }
    }


    //Add a couple of emacs key bindings for navigation.
    protected void addBindings() {
        InputMap inputMap = textPane.getInputMap();

        //Ctrl-b to go backward one character
        KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_B, Event.CTRL_MASK);
        inputMap.put(key, DefaultEditorKit.backwardAction);

        //Ctrl-f to go forward one character
        key = KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK);
        inputMap.put(key, DefaultEditorKit.forwardAction);

        //Ctrl-p to go up one line
        key = KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK);
        inputMap.put(key, DefaultEditorKit.upAction);

        //Ctrl-n to go down one line
        key = KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK);
        inputMap.put(key, DefaultEditorKit.downAction);
    }

    //Create the File menu.
    protected JMenu createFileMenu() {
        JMenu menu = new JMenu("File");

        //New , Open , Save and Exit are actions of my own creation.
        menu.add(new NewAction());
        menu.addSeparator();
        menu.add(new OpenAction());
        menu.add(new SaveAction());
        menu.add(new SaveAsAction());
        menu.addSeparator();
        menu.add(new ExitAction());
        return menu;
    }

    //Create the About menu.
    protected JMenu createAboutMenu() {
        JMenu menu = new JMenu("About");
        menu.add(new AboutAction());
        return menu;
    }

    //Create the edit menu.
    protected JMenu createEditMenu() {
        JMenu menu = new JMenu("Edit");
        //Undo and redo are actions of our own creation.
        undoAction = new UndoAction();
        menu.add(undoAction);
        redoAction = new RedoAction();
        menu.add(redoAction);
        menu.addSeparator();
        //These actions come from the default editor kit.
        //Get the ones we want and stick them in the menu.
        menu.add(getActionByName(DefaultEditorKit.cutAction));
        menu.add(getActionByName(DefaultEditorKit.copyAction));
        menu.add(getActionByName(DefaultEditorKit.pasteAction));
        menu.addSeparator();
        menu.add(getActionByName(DefaultEditorKit.selectAllAction));
        menu.add(new deleteCommentAction());
        return menu;
    }

    //Create the style menu.
    protected JMenu createStyleMenu() {
        JMenu menu = new JMenu("Style");

        Action action = new StyledEditorKit.BoldAction();
        action.putValue(Action.NAME, "Bold");
        menu.add(action);

        action = new StyledEditorKit.ItalicAction();
        action.putValue(Action.NAME, "Italic");
        menu.add(action);

        action = new StyledEditorKit.UnderlineAction();
        action.putValue(Action.NAME, "Underline");
        menu.add(action);

        menu.addSeparator();

        menu.add(new StyledEditorKit.FontSizeAction("12", 12));
        menu.add(new StyledEditorKit.FontSizeAction("14", 14));
        menu.add(new StyledEditorKit.FontSizeAction("18", 18));

        menu.addSeparator();

        menu.add(new StyledEditorKit.FontFamilyAction("Serif",
                "Serif"));
        menu.add(new StyledEditorKit.FontFamilyAction("SansSerif",
                "SansSerif"));

        menu.addSeparator();

        menu.add(new StyledEditorKit.ForegroundAction("Red",
                Color.red));
        menu.add(new StyledEditorKit.ForegroundAction("Green",
                Color.green));
        menu.add(new StyledEditorKit.ForegroundAction("Blue",
                Color.blue));
        menu.add(new StyledEditorKit.ForegroundAction("Black",
                Color.black));

        return menu;
    }

    protected SimpleAttributeSet[] initAttributes(int length) {
        //Hard-code some attributes.
        SimpleAttributeSet[] attrs = new SimpleAttributeSet[length];

        attrs[0] = new SimpleAttributeSet();
        StyleConstants.setFontFamily(attrs[0], "SansSerif");
        StyleConstants.setFontSize(attrs[0], 16);

        attrs[1] = new SimpleAttributeSet(attrs[0]);
        StyleConstants.setBold(attrs[1], true);

        attrs[2] = new SimpleAttributeSet(attrs[0]);
        StyleConstants.setItalic(attrs[2], true);

        attrs[3] = new SimpleAttributeSet(attrs[0]);
        StyleConstants.setFontSize(attrs[3], 20);

        attrs[4] = new SimpleAttributeSet(attrs[0]);
        StyleConstants.setFontSize(attrs[4], 12);

        attrs[5] = new SimpleAttributeSet(attrs[0]);
        StyleConstants.setForeground(attrs[5], Color.red);

        return attrs;
    }

    //The following two methods allow us to find an
    //action provided by the editor kit by its name.
    private void createActionTable(JTextComponent textComponent) {
        actions = new HashMap();
        Action[] actionsArray = textComponent.getActions();
        for (int i = 0; i < actionsArray.length; i++) {
            Action a = actionsArray[i];
            actions.put(a.getValue(Action.NAME), a);
        }
    }

    private Action getActionByName(String name) {
        return (Action) (actions.get(name));
    }

    // delete Comment Action
    class deleteCommentAction extends AbstractAction {
        deleteCommentAction() {
            super("Delete Comment");
            setEnabled(true);
        }

        public void actionPerformed(ActionEvent e) {
            StringBuffer content = new StringBuffer(textPane.getText());
            deleteinfo(content, 0);
            textPane.setText(new String(content));
        }
    }


    void deleteinfo(StringBuffer content, int pos) {
        for (int i = pos; i < content.length() - 1; i++) {
            int start = i;
            int end = i + 2;
            if (content.substring(start, start + 2).equals("//")) { //end index shoud be exclusive

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人在线综合网| 91精品国产综合久久久久久久久久 | 欧美一区三区二区| 亚洲精品自拍动漫在线| 懂色av一区二区三区免费看| 亚洲精品欧美综合四区| 精品国产亚洲一区二区三区在线观看 | 亚洲裸体在线观看| 精品日韩一区二区三区| 91麻豆福利精品推荐| 青青青爽久久午夜综合久久午夜| 欧美日韩亚洲丝袜制服| 国产日韩高清在线| 日本一区二区三区国色天香| 日本不卡一区二区三区高清视频| 久久精品国产亚洲5555| 欧美日韩国产综合视频在线观看| 一区二区三区国产精品| 欧美国产精品中文字幕| 久久综合九色综合97_久久久| 日本一区二区三区高清不卡| 欧美一卡2卡三卡4卡5免费| 欧美在线free| 色综合久久中文综合久久牛| 波多野结衣一区二区三区 | 色综合久久天天| 丁香五精品蜜臀久久久久99网站| 韩国女主播一区| 精品午夜一区二区三区在线观看| 色丁香久综合在线久综合在线观看| 依依成人综合视频| 亚洲欧美激情视频在线观看一区二区三区| 精品美女一区二区三区| 日韩精品一区二区三区中文不卡 | 日韩免费电影网站| 欧美区一区二区三区| 欧美日韩一级二级三级| 欧美视频一区二区三区在线观看| 91国内精品野花午夜精品| 色婷婷国产精品综合在线观看| 97久久精品人人爽人人爽蜜臀 | 在线观看三级视频欧美| 一本色道久久综合狠狠躁的推荐 | 精品一区精品二区高清| 六月丁香综合在线视频| 看片的网站亚洲| 国产真实乱子伦精品视频| 国内一区二区在线| 丁香亚洲综合激情啪啪综合| 97久久精品人人爽人人爽蜜臀| av一区二区三区黑人| 欧美最新大片在线看| 欧美乱妇20p| 欧美va亚洲va香蕉在线| 国产午夜精品一区二区| 亚洲欧洲另类国产综合| 一区二区免费视频| 午夜精品久久久| 国产人成一区二区三区影院| 欧美经典一区二区三区| 欧美一区二区三区免费| 欧美三区在线视频| 欧美一级久久久久久久大片| 97久久久精品综合88久久| 成人激情黄色小说| kk眼镜猥琐国模调教系列一区二区 | 亚洲欧洲av色图| 欧美国产成人在线| 亚洲三级免费电影| 亚洲h在线观看| 久久爱www久久做| 处破女av一区二区| 欧美三级韩国三级日本三斤| 精品sm在线观看| 亚洲欧洲99久久| 日韩va欧美va亚洲va久久| 国产乱人伦偷精品视频免下载| 91毛片在线观看| 日本aⅴ亚洲精品中文乱码| 一区二区三区蜜桃| 美女视频黄 久久| 成a人片亚洲日本久久| 91精品国产91久久综合桃花| 久久精品亚洲麻豆av一区二区| 亚洲美女精品一区| 久久se这里有精品| 91首页免费视频| 日韩视频免费直播| 亚洲麻豆国产自偷在线| 麻豆传媒一区二区三区| 国产一区二区三区最好精华液| 欧洲一区二区av| 久久午夜羞羞影院免费观看| 亚洲一区二区三区三| 国产传媒一区在线| 91精品国产91综合久久蜜臀| 椎名由奈av一区二区三区| 美国十次了思思久久精品导航| 一本到三区不卡视频| 久久久久久9999| 美女一区二区三区在线观看| 色综合欧美在线视频区| 久久亚洲一级片| 久久国产精品一区二区| 欧美视频一区二区| 亚洲人成在线观看一区二区| 国内精品在线播放| 777亚洲妇女| 亚洲精品免费在线| 99视频热这里只有精品免费| 久久午夜免费电影| 日本成人在线不卡视频| 欧美日韩一区在线| 亚洲人成亚洲人成在线观看图片| 国产成人夜色高潮福利影视| 在线亚洲+欧美+日本专区| 国产精品久久久久婷婷二区次| 国产伦精一区二区三区| 欧美一区二区三区免费在线看 | 日韩精品一区二区三区在线 | 日韩一区二区免费在线观看| 亚洲亚洲精品在线观看| 99久久久久久99| 国产精品国产三级国产| 国产.精品.日韩.另类.中文.在线.播放 | 麻豆精品视频在线观看| 欧美日韩在线播| 亚洲福利一二三区| 在线免费观看日本欧美| 自拍偷拍欧美精品| 成人av在线播放网址| 国产欧美日本一区视频| 国产成人精品影视| 国产精品天天看| 国产一区福利在线| 久久精品欧美日韩精品| 国产精一品亚洲二区在线视频| 欧美mv日韩mv国产网站| 日韩精品一区在线| 日韩伦理电影网| 91久久香蕉国产日韩欧美9色| 亚洲免费资源在线播放| 欧美又粗又大又爽| 亚洲成人中文在线| 欧美一区二区三区公司| 久久国产日韩欧美精品| 2024国产精品| 丰满岳乱妇一区二区三区 | 五月天欧美精品| 91精品国产色综合久久不卡电影| 视频一区欧美日韩| 亚洲精品一区二区三区香蕉| 国产精品一区二区在线观看网站 | 欧美成人三级在线| 国产一区二区视频在线播放| 国产精品美女www爽爽爽| 色综合久久中文综合久久牛| 亚洲国产精品欧美一二99| 日韩色在线观看| 国产一区二区看久久| 国产精品你懂的| 欧美美女一区二区在线观看| 九一久久久久久| 一色桃子久久精品亚洲| 欧美日本视频在线| 国产精品99久| 亚洲精品成人悠悠色影视| 日韩欧美国产综合一区| jizzjizzjizz欧美| 亚洲电影一区二区三区| 久久久久久99精品| 在线免费观看日本欧美| 狠狠色丁香婷婷综合久久片| 中文字幕在线一区二区三区| 欧美日韩1区2区| 国产成人高清视频| 午夜激情一区二区| 国产精品色哟哟| 欧美美女直播网站| 成人免费视频播放| 日韩影院免费视频| 日本一区二区三区视频视频| 欧美视频第二页| 国产精品1024| 日日夜夜免费精品视频| 国产精品天美传媒| 91麻豆精品国产自产在线观看一区 | 亚洲午夜免费视频| 欧美精品一区男女天堂| 91蝌蚪国产九色| 国产一区三区三区| 一二三四社区欧美黄| 国产视频一区不卡| 欧美日韩另类国产亚洲欧美一级| 国产99久久久久| 日韩精品一级中文字幕精品视频免费观看 | 国产ts人妖一区二区| 一个色综合网站| 国产精品丝袜黑色高跟| 精品国产电影一区二区|