当前位置: 技术问答>java相关
超菜问题,在线等待
来源: 互联网 发布时间:2015-08-12
本文导语: 怎样从文本框了接收数字。进行排序然后再在文本框里显示结果,具体该怎样写?谢谢! | import java.util.*; .... TextArea textArea; .... public void doSort() { String text = textArea.getText(); String...
怎样从文本框了接收数字。进行排序然后再在文本框里显示结果,具体该怎样写?谢谢!
|
import java.util.*;
....
TextArea textArea;
....
public void doSort() {
String text = textArea.getText();
StringTokenizer st = new StringTokenizer (text, " trn") ;
Vector v = new Vector ();
while(st.hasMoreTokens()) {
String s = st.nextToken();
try{ Integer.parseInt(s); }
catch(NumberFormatException e ) {continue;}
v.addElement(s);
}
String [] nums = v.toArray(new String[0]);
Arrays.sort(nums);
text = "";
for(int i=0;i
....
TextArea textArea;
....
public void doSort() {
String text = textArea.getText();
StringTokenizer st = new StringTokenizer (text, " trn") ;
Vector v = new Vector ();
while(st.hasMoreTokens()) {
String s = st.nextToken();
try{ Integer.parseInt(s); }
catch(NumberFormatException e ) {continue;}
v.addElement(s);
}
String [] nums = v.toArray(new String[0]);
Arrays.sort(nums);
text = "";
for(int i=0;i