close

JFormattedTextField的getValue() 他回傳是Object因此你並不知道它是什類型可能是Long也可能是Integer...

這真的很麻煩 我的方法有2種

1.最笨的方法

既然是數字哪就把取得到的數字直接toString() 然後再利用Integer.valueOf(string)這樣就取得到數字嚕
範例:
        int i = Integer.valueOf(jFormattedTextField.getValue().toString());


2.比較好一點的方法

利用instanceof來判斷是什麼物件


3.應該有更好的方法,尚未想到

arrow
arrow
    全站熱搜

    eric1300460 發表在 痞客邦 留言(0) 人氣()