一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

用Applet读写XML配置文件

时间:2022-07-02 17:56:13 编辑:袖梨 来源:一聚教程网

此小程序用DOM来读取XML文件,用DOM4j来写XML文件。
DOM4j下载地址:http://sourceforge.net/projects/dom4j
1、Applet主程序mainFrame.java
package frame;
/**
* @author wls
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class mainFrame
extends Applet {
DomXml domxml = new DomXml();
Button btnExit = new Button("Exit");
Button btnRun = new Button("Save");
Label lblMain = new Label("dynamicroute.xml配置文件");
Label lblSiteinfo = new Label("srcserverid:");
Label lblPath = new Label("destserverid:");
Label lblFilename = new Label("switchserver:");
Label lblSession = new Label("metric:");
Label lblSuccess = new Label(" ");
TextField txtSiteinfo = new TextField(domxml.getSrcserverid(), 10);
TextField txtPath = new TextField(domxml.getDestserverid(), 10);
TextField txtFilename = new TextField(domxml.getSwitchserver(), 10);
TextField txtSession = new TextField(domxml.getMetric(), 10);
Panel p6 = new Panel();
Panel p1 = new Panel();
Panel p2 = new Panel();
Panel p3 = new Panel();
Panel p4 = new Panel();
Panel p5 = new Panel();
Panel p7 = new Panel();
Panel p8 = new Panel();
public void init() {
resize(400, 300);
p6.add(lblMain);
p1.add(lblSiteinfo);
p1.add(txtSiteinfo);
p2.add(lblPath);
p2.add(txtPath);
p3.add(lblSession);
p3.add(txtSession);
p4.add(btnRun);
p4.add(btnExit);
p5.add(lblFilename);
p5.add(txtFilename);
p8.add(lblSuccess);
setLayout(new GridLayout(4, 2, 1, 1));
add(p6);
add(p7);
add(p1);
add(p2);
add(p5);
add(p3);
add(p4);
add(p8);

热门栏目