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

📄 quizwizard.java

📁 eclipse平台的CDT项目3.0版本的源代码
💻 JAVA
字号:
package cdt.projects.tree.wizards.quiz;import cdt.projects.Project;import cdt.projects.tree.nodes.Hold;import cdt.projects.tree.nodes.Node;import cdt.projects.tree.nodes.Wizard;import cdt.wizard.WizardFrame;import javax.swing.*;import javax.swing.text.Position;import javax.swing.tree.TreePath;import java.util.Enumeration;import java.awt.*;/** * Initiates a wizard to create a quiz in a project. */public class QuizWizard extends WizardFrame {        /** The JFrame acting as the parent to this wizard. */    private JFrame parent;    /** The Node representing the 'Quiz/Questions' folder. */    private Node questionsFolder;    /** The Node representing the 'Quiz/Answers' folder. */    private Node answersFolder;    /**     * Creates the quiz wizard.     *     * @param parent The parent JFrame, in this case typically an instance of     *      {@link cdt.Frame1 Frame1}.     */    public QuizWizard(JFrame parent) {        super(parent);        this.parent = parent;        this.questionsFolder = null;        this.answersFolder = null;        JTree projectTree = Project.currentProject.getTree();        // Finds the 'Quiz' folder in the ProjectTree        TreePath treePath = projectTree.getNextMatch("Quiz", 0, Position.Bias.Forward);        Node quizFolder = null;        if(null != treePath) {            quizFolder = (Node)treePath.getLastPathComponent();        } else {            quizFolder = new Hold("Quiz");            quizFolder.setFile(Node.foldername(quizFolder.getName()));            Hold rootNode = (Hold)projectTree.getPathForRow(0).getLastPathComponent();            rootNode.addNodeInto(quizFolder);        }        // Finds the 'Create a quiz' node and removes it if it finds it        treePath = projectTree.getNextMatch("Create a quiz", 0, Position.Bias.Forward);        if(null != treePath) {            Node n = (Node)treePath.getLastPathComponent();            if(n instanceof Wizard) {                n.removeNode();            }        }        // Finds the 'Quiz/Questions' folder, or creates it if it cannot be found        Enumeration enum = quizFolder.children();        while(enum.hasMoreElements()) {            Node temp = (Node)enum.nextElement();            if(temp.getName().equals("Questions")) {                this.questionsFolder = temp;                break;            }        }        if(null == questionsFolder) {            this.questionsFolder = new Hold("Questions");            this.questionsFolder.setFile(Node.foldername(this.questionsFolder.getName()));            quizFolder.addNodeInto(this.questionsFolder);            projectTree.updateUI();        }        // Finds the 'Quiz/Answers' folder, or creates it if it cannot be found        enum = quizFolder.children();        while(enum.hasMoreElements()) {            Node temp = (Node)enum.nextElement();            if(temp.getName().equals("Answers") && temp instanceof Hold) {                this.answersFolder = temp;                break;            }        }        if(null == this.answersFolder) {            this.answersFolder = new Hold("Answers");            this.answersFolder.setFile(Node.foldername(this.answersFolder.getName()));            quizFolder.addNodeInto(this.answersFolder);        }        // Adds a wizard node into the quiz folder        enum = quizFolder.children();        boolean foundWizard = false;        while(enum.hasMoreElements()) {            Node temp = (Node)enum.nextElement();            if(temp instanceof Wizard && temp.getName().equals("Modify quiz")) {                foundWizard = true;                break;            }        }        if(false == foundWizard) {            Wizard wiz = new Wizard();            wiz.setWizardType(Wizard.QUIZ_WIZARD);            wiz.setName("Modify quiz");            quizFolder.addNodeInto(wiz);        }        projectTree.updateUI();        putData("oldQuestionsFolder", this.questionsFolder);        putData("oldAnswersFolder", this.answersFolder);        init();    }    /**     * Sets up the layout of this page.     */    public void customize() {        showPreviousButton(false);        showFinishButton(false);        setTitle("Quiz Wizard");        JPanel panel = new JPanel(new BorderLayout());        panel.add(new JLabel("This wizard creates a new Quiz, and will overwrite any old quiz that you may have"),                BorderLayout.NORTH);        panel.add(new JLabel(" "), BorderLayout.CENTER);        panel.add(new JLabel("Please hit the 'next' button to begin the quiz creation process."),                BorderLayout.SOUTH);        centerPanel.add(panel);    }        /**     * Moves to the next page in the wizard.     */    public void nextAction() {        pushFrame(this);        setVisible(false);        // Creates the folder to store the new quiz in        data.put("newQuestionsFolder", new Hold("Questions"));        data.put("newAnswersFolder", new Hold("Answers"));        Project.currentProject.getTree().firePageNeededEvent();        // Creates the next page in the wizard        new QuizWizard1(parent);    }}

⌨️ 快捷键说明

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