同时运行多个JFrame

时间:2018-08-14 18:50:27

标签: jframe

我有这样的代码:

public static void main(String[] args) throws Exception{
    Display display = new Display();
    Display display2 = new Display();
    Thread thread = new Thread(display);
    Thread thread2 = new Thread(display2);
    thread.start();
    thread2.start();
}

显示类别:

public class Display() extends Canvas implements Runnable {
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getId());
        f.setVisible(true);
    }

     public void paint(Graphics g) {
          //do something
     }
}

同时输出输出日志:

15
16

它必须在第一个JFrame中完成paint(),然后第二个JFrame开始运行。我看着这样的问题的答案,但我使用的是其他方法,但仍然无法正常工作。

0 个答案:

没有答案
相关问题