帮我看看这段代码怎么修改一下!非常着急!!!谢谢了!@
目的是将都到的文档从textfile里一行一行的读到textarea里。点击开始的时候开始运行,点击停止的时候停止运行。再点击开始的时候继续读!(是继续读)!!!clas...
目的是将都到的文档从textfile里一行一行的读到textarea里。点击开始的时候开始运行,点击停止的时候停止运行。再点击开始的时候继续读!(是继续读)!!!
class ReadFile extends Thread {
private boolean begin = false;
private JTextArea jtaContent;
private JTextArea jtaFile;
public void run () {
BufferedReader br = null;
try {
br = new BufferedReader(
new InputStreamReader(
new FileInputStream(new File(jtaFile.getText().trim()))));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String str = "";
while (true) {
if (begin) {
try {
str = br.readLine();
if (str == null) {
break;
}
jtaContent.setText(jtaContent.getText() + "\n" + str);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// 休眠1秒
try {
sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
* @return the begin
*/
public boolean isBegin() {
return begin;
}
/**
* @param begin the begin to set
*/
public void setBegin(boolean begin) {
this.begin = begin;
}
/**
* @param jtaContent the jtaContent to set
*/
public void setJtaContent(JTextArea jtaContent) {
this.jtaContent = jtaContent;
}
/**
* @param jtaFile the jtaFile to set
*/
public void setJtaFile(JTextArea jtaFile) {
this.jtaFile = jtaFile;
}
} 展开
class ReadFile extends Thread {
private boolean begin = false;
private JTextArea jtaContent;
private JTextArea jtaFile;
public void run () {
BufferedReader br = null;
try {
br = new BufferedReader(
new InputStreamReader(
new FileInputStream(new File(jtaFile.getText().trim()))));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String str = "";
while (true) {
if (begin) {
try {
str = br.readLine();
if (str == null) {
break;
}
jtaContent.setText(jtaContent.getText() + "\n" + str);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// 休眠1秒
try {
sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
* @return the begin
*/
public boolean isBegin() {
return begin;
}
/**
* @param begin the begin to set
*/
public void setBegin(boolean begin) {
this.begin = begin;
}
/**
* @param jtaContent the jtaContent to set
*/
public void setJtaContent(JTextArea jtaContent) {
this.jtaContent = jtaContent;
}
/**
* @param jtaFile the jtaFile to set
*/
public void setJtaFile(JTextArea jtaFile) {
this.jtaFile = jtaFile;
}
} 展开
1个回答
展开全部
Private Sub Command1_Click()
Dim a As String
Dim b() As String
Dim i, j As Integer
a = Text1.Text
b = Split(a, " ")
For i = 0 To 5 '这里改成 0-5
For j = i+1 To 5 '这也要改改,不然不是从小到大排列
If Val(b(i)) > Val(b(j)) Then
temp = b(i): b(i) = b(j): b(j) = temp
End If
Next j
Next i
sptx = Join(b, " ")
Text2.Text = sptx
End Sub
Dim a As String
Dim b() As String
Dim i, j As Integer
a = Text1.Text
b = Split(a, " ")
For i = 0 To 5 '这里改成 0-5
For j = i+1 To 5 '这也要改改,不然不是从小到大排列
If Val(b(i)) > Val(b(j)) Then
temp = b(i): b(i) = b(j): b(j) = temp
End If
Next j
Next i
sptx = Join(b, " ")
Text2.Text = sptx
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询