程序設計
摘要: 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();
}
閱讀全文
摘要: 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
* 本方法不處理任何異常
閱讀全文
摘要: 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 {
閱讀全文
摘要: 下面就是在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(); //輸出錯誤
閱讀全文
摘要: 本人的思路是讓程序去訪問(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
閱讀全文