Java線程實(shí)現(xiàn)時(shí)間動(dòng)態(tài)顯示
本文實(shí)例為大家分享了Java線程實(shí)現(xiàn)時(shí)間動(dòng)態(tài)顯示的具體代碼,供大家參考,具體內(nèi)容如下
代碼如下:
import javax.swing.*;import java.awt.*;import java.util.Date;public class Test1 { public static void main(String[] args) {JFrame frame = new JFrame('我的窗口');frame.setBounds(200,200,400,400);JTextField textField=new JTextField();frame.add(textField);new Thread(new Runnable() { @Override public void run() {while(true){ try {Thread.sleep(1000); } catch (InterruptedException e) {e.printStackTrace(); } Date date=new Date(); textField.setText(date.getHours()+':'+date.getMinutes()+':'+date.getSeconds()); textField.setFont(new Font('楷體',Font.BOLD,20));} }}).start();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true); }}
運(yùn)行結(jié)果:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 使用Python webdriver圖書(shū)館搶座自動(dòng)預(yù)約的正確方法2. Linux刪除系統(tǒng)自帶版本Python過(guò)程詳解3. ASP基礎(chǔ)知識(shí)VBScript基本元素講解4. Python 合并拼接字符串的方法5. Python 利用Entrez庫(kù)篩選下載PubMed文獻(xiàn)摘要的示例6. Python3 json模塊之編碼解碼方法講解7. Python 制作查詢商品歷史價(jià)格的小工具8. ASP.NET MVC使用jQuery ui的progressbar實(shí)現(xiàn)進(jìn)度條9. Python sublime安裝及配置過(guò)程詳解10. python 使用事件對(duì)象asyncio.Event來(lái)同步協(xié)程的操作

網(wǎng)公網(wǎng)安備