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

📄 xmldrivendemo.java

📁 全面实现ilog地功能,没有使用第三方lib.
💻 JAVA
字号:
/* * This source code is part of TWaver 1.3.1 * * SERVA Software PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * Copyright 2000-2005 SERVA Software, Inc. All rights reserved. */package demo.databox;

import java.io.*;
import java.awt.*;
import javax.swing.*;
import demo.*;
import twaver.*;
import twaver.network.*;

public class XMLDrivenDemo extends DemoPane {
    TDataBox box = new TDataBox();
    TNetwork network = new TNetwork(box);
    String[] xmlContents = new String[] {"", "", ""};
    JTextArea textArea=new JTextArea();

    public XMLDrivenDemo() {
        this.setLayout(new BorderLayout());

        JSplitPane split=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        split.setLeftComponent(network);
        split.setRightComponent(new JScrollPane(textArea));
        split.setContinuousLayout(true);
        split.setLastDividerLocation(300);

        this.add(split, BorderLayout.CENTER);

        readFiles();

        TaskScheduler.getInstance().register(new TaskAdapter() {
            String fileName = "remove.xml";
            public void run(long clock) {
                try {
                    int xmlContentsIndex;
                    if (fileName.equals("remove.xml")) {
                        fileName = "create.xml";
                        xmlContentsIndex=0;
                    } else if (fileName.equals("update.xml")) {
                        fileName = "remove.xml";
                        xmlContentsIndex=2;
                    } else {
                        fileName = "update.xml";
                        xmlContentsIndex=1;
                    }
                    box.parse("/demo/resource/xmldriven/" + fileName);
                    textArea.setText(xmlContents[xmlContentsIndex]);
                }
                catch (Exception ex) {
                }
            }

            public int getInterval() {
                return 1000;
            }
        });
    }

    private void readFiles() {
        String[] filenames = new String[] {
            "/demo/resource/xmldriven/create.xml",
            "/demo/resource/xmldriven/update.xml",
            "/demo/resource/xmldriven/remove.xml",
        };
        try {
            for (int i = 0; i < filenames.length; i++) {
                InputStream input = getClass().getResource(filenames[i]).openStream();
                BufferedReader reader = new BufferedReader(new InputStreamReader(input));
                String line = reader.readLine();
                while (line != null) {
                    xmlContents[i] = xmlContents[i] + line + "\n";
                    line = reader.readLine();
                }
                reader.close();
                input.close();
            }
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public String getTitle() {
        return "XML Driven Demo";
    }

    public String getHelp() {
        return "This demo create, update and remove a node by XML";
    }
}

⌨️ 快捷键说明

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