[Java] java窗体 自定义JFrame类 →→→→→进入此内容的聊天室

来自 , 2019-02-10, 写在 Java, 查看 131 次.
URL http://www.code666.cn/view/7c590f01
  1. import javax.swing.*;
  2.  
  3. import java.util.concurrent.*;
  4.  
  5. public class SubmitSwingProgram extends JFrame {
  6.  
  7.     JLabel label;
  8.  
  9.     public SubmitSwingProgram() {
  10.  
  11.         super("Hello Swing");
  12.  
  13.         label = new JLabel("A Label");
  14.  
  15.         add(label);
  16.  
  17.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  18.  
  19.         setSize(300, 100);
  20.  
  21.         setVisible(true);
  22.  
  23.     }
  24.  
  25.     static SubmitSwingProgram ssp;
  26.  
  27.     public static void main(String[] args) throws Exception
  28.  
  29.     {
  30.  
  31.         SwingUtilities.invokeLater(new Runnable() {
  32.  
  33.             public void run() {
  34.                 ssp = new SubmitSwingProgram();
  35.             }
  36.  
  37.         });
  38.  
  39.         TimeUnit.SECONDS.sleep(1);
  40.  
  41.         SwingUtilities.invokeLater(new Runnable() {
  42.  
  43.             public void run() {
  44.  
  45.                 ssp.label.setText("Hey! This is Different!");
  46.  
  47.             }
  48.  
  49.         });
  50.  
  51.     }
  52.  
  53. }

回复 "java窗体 自定义JFrame类"

这儿你可以回复上面这条便签

captcha