01/10/2018, 12:11

SwingUtilities.invokeLater(new Runnable() nghĩa là gì,dùng như thế nào

Mình không hiểu lắm dòng lệnh này.xem video mình code dc ntn
mn thông cảm.tại ms làm quen vs swing sợ quên cách dùng nên cmt dễ nhớ ^^

package swing.app;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class SwingApp {

   
    public static void main(String[] args) {
         SwingUtilities.invokeLater(new Runnable(){
             
             public void run() {
         JFrame sc=new JFrame("Welcome to my app");
         sc.setVisible(true); // hiện giao diện
         sc.setResizable(true); // nút cho phép kéo giao diện,nếu là false thì ko kéo dc.còn ko cần câu lệnh trên là đủ
         sc.setSize(600,600); //thiết lập kích thước 
         sc.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// nút tắt mặc định bản cũ(bao hàm trong setvisible
             }
             
         });
        
         
    }
    
}
Thành Nguyễn viết 14:24 ngày 01/10/2018

sao ko bạn nào rep thế @@

Bài liên quan
0