java textArea如何追加显示文字
据说用多线程,但是我不会,求大家帮忙!btnRun.addMouseListener(newMouseAdapter(){@Overridepublicvoidmouse...
据说用多线程,但是我不会,求大家帮忙!
btnRun.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
String date = textField.getText();
textArea.setText("Now running "+date+" mobile phone bill");
UpdateBigBill ubb = new UpdateBigBill();
ubb.updateBigBill(date);
textArea.setText("Finish updating Big Bill");
RunDeptBill rdb = new RunDeptBill();
rdb.runDeptBill(date);
textArea.setText("<<Finish running Dept Bill>>");
RunMngBill_Summary rmbs = new RunMngBill_Summary();
rmbs.runMngBill_Summary(date);
textArea.setText("<<Finish running Manager Summary Bill>>");
UpdateLocalBill ulb = new UpdateLocalBill();
ulb.updateLocalBill(date);
textArea.setText("Finish updating Local Bill");
RunMngBill_Local rmbl = new RunMngBill_Local();
rmbl.runMngBill_Local(date);
textArea.setText("<<Finish running Local Bill>>");
UpdateRoamingLongBill urlb = new UpdateRoamingLongBill();
urlb.updateRoamingLongBill(date);
textArea.setText("Finish updating Roam&Long Bill");
RunMngBill_IDD rmbi = new RunMngBill_IDD();
rmbi.runMngBill_IDD(date);
textArea.setText("<<Finish running IDD Bill>>");
RunMngBill_DDD rmbd = new RunMngBill_DDD();
rmbd.runMngBill_DDD(date);
textArea.setText("<<Finish running DDD Bill>>");
}
});
我想没运行完一个,就显示下内容,但是setText只会覆盖前面的
真心着急,求大家帮忙!! 展开
btnRun.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
String date = textField.getText();
textArea.setText("Now running "+date+" mobile phone bill");
UpdateBigBill ubb = new UpdateBigBill();
ubb.updateBigBill(date);
textArea.setText("Finish updating Big Bill");
RunDeptBill rdb = new RunDeptBill();
rdb.runDeptBill(date);
textArea.setText("<<Finish running Dept Bill>>");
RunMngBill_Summary rmbs = new RunMngBill_Summary();
rmbs.runMngBill_Summary(date);
textArea.setText("<<Finish running Manager Summary Bill>>");
UpdateLocalBill ulb = new UpdateLocalBill();
ulb.updateLocalBill(date);
textArea.setText("Finish updating Local Bill");
RunMngBill_Local rmbl = new RunMngBill_Local();
rmbl.runMngBill_Local(date);
textArea.setText("<<Finish running Local Bill>>");
UpdateRoamingLongBill urlb = new UpdateRoamingLongBill();
urlb.updateRoamingLongBill(date);
textArea.setText("Finish updating Roam&Long Bill");
RunMngBill_IDD rmbi = new RunMngBill_IDD();
rmbi.runMngBill_IDD(date);
textArea.setText("<<Finish running IDD Bill>>");
RunMngBill_DDD rmbd = new RunMngBill_DDD();
rmbd.runMngBill_DDD(date);
textArea.setText("<<Finish running DDD Bill>>");
}
});
我想没运行完一个,就显示下内容,但是setText只会覆盖前面的
真心着急,求大家帮忙!! 展开
3个回答
展开全部
可以直接用TextArea的append方法进行追加即可,之后会自动进行显示的。
代码举例:
TextArea ta_log = new JTextArea(10,10);
ta_log.setLineWrap(true);
ta_log.setWrapStyleWord(true);
JScrollPane p_log = new JScrollPane(ta_log);
ta_log.append(“我是追加的内容”);
ta_log.append("\r\n");
代码举例:
TextArea ta_log = new JTextArea(10,10);
ta_log.setLineWrap(true);
ta_log.setWrapStyleWord(true);
JScrollPane p_log = new JScrollPane(ta_log);
ta_log.append(“我是追加的内容”);
ta_log.append("\r\n");
展开全部
请注意,TextArea有一个方法,append(str);就是在当前文本框末尾添加字符。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
textArea.setText(textArea.getText()+"你要追加的内容");
就可以了
就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询