程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> 用Applet讀寫XML配置文件

用Applet讀寫XML配置文件

編輯:關於JSP

此小程序用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);

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved