数据加载中……

程序设计

JAVA:JTextField文本框输入过滤
     摘要: import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;

public class LimitedDocument extends PlainDocument {

private int maxLength = -1;
private String allowCharAsString = null;

public LimitedDocument() {
super();
}  阅读全文

posted @ 2009-05-25 10:32 YeeYang 阅读(886) | 评论 (0)  编辑

JAVA:DES可逆加密算法
     摘要: import java.security.*;
import javax.crypto.*;

public class DESPlus {
private static String strDefaultKey = "national";
private Cipher encryptCipher = null;
private Cipher decryptCipher = null;

/**
* 将byte数组转换为表示16进制值的字符串, 如:byte[]{8,18}转换为:0813, 和public static byte[]
* hexStr2ByteArr(String strIn) 互为可逆的转换过程
*
* @param arrB
* 需要转换的byte数组
* @return 转换后的字符串
* @throws Exception
* 本方法不处理任何异常  阅读全文

posted @ 2009-05-24 11:18 YeeYang 阅读(6632) | 评论 (0)  编辑

JAVA:MD5不可逆加密算法
     摘要: import java.security.MessageDigest;
import java.security.*;
import java.security.spec.*;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
public class MD5 {  阅读全文

posted @ 2009-05-23 10:27 YeeYang 阅读(696) | 评论 (0)  编辑

JAVA:对JFrame窗口的一些操作(个人累积)
     摘要: 下面就是在jFrame下的一些方法经验积累,可能很微小很不起眼,或许对新手有点点帮助,我会不定时更新一下的:

1)改变界面为系统默认状态:
1 //需要导入这个包
2 import javax.swing.UIManager;
3
4 //改变界面为系统默认状态
5
6 try {
7
8 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //设置界面样式
9
10 javax.swing.SwingUtilities.updateComponentTreeUI(this); //更新界面
11
12 } catch (Exception ex) { //捕捉错误
13
14 ex.printStackTrace(); //输出错误  阅读全文

posted @ 2009-05-22 10:35 YeeYang 阅读(690) | 评论 (0)  编辑

JAVA:获取本机外网IP地址的小工具
     摘要: 本人的思路是让程序去访问(HttpURLConnection)一个可以查IP地址的,然后把这个网页下载(FileOutputStream)到本地,通过(BufferedReader)去读取那个临时文件,最后通过操作文件(File),把临时文件删除,并以弹出“对话框”形式把获取的“外网 IP”显示出来。

提供几个查IP反回页面相对简单的网址,访问不同的网址,读取关键字符串的时候可能会不同,请做出相应的修改。

http://www.bliao.com/ip.phtml
http://www.5di1.com/getip/getip.asp
http://www.m5home.com/myip
http://vbnet.mvps.org/resources/tools/getpublicip.shtml  阅读全文

posted @ 2009-05-19 23:35 YeeYang 阅读(5692) | 评论 (3)  编辑