Facebook
From Speedy Leech, 5 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 266
  1. import gui.*;
  2.  
  3. import java.awt.*;
  4. import javax.swing.*;
  5.  
  6.  
  7. public class Main {
  8.     static class MyThread implements Runnable {
  9.         public void run() {
  10.             createGUI();
  11.         }
  12.     }
  13.  
  14.     static class Thread2 implements Runnable {
  15.         public void run() {
  16.             for(int i = 0; i < 10; i++) {
  17.                 System.out.println(i);
  18.                 try {
  19.                     Thread.sleep(1000);
  20.                 }
  21.                 catch (InterruptedException e) {
  22.                     return;
  23.                 }
  24.             }
  25.         }
  26.     }
  27.  
  28.     public static void main(String[] args) {
  29.         Thread thread = new Thread(new MyThread());
  30.         Thread thread1 = new Thread(new Thread2());
  31.  
  32.         thread.start();
  33.         thread1.start();
  34.         //createGUI();
  35.     }
  36.  
  37.     public static void createGUI() {
  38.         JFrame frame = new JFrame("Title");
  39.         Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
  40.         int width = 800;
  41.         int height = 500;
  42.  
  43.         frame.setVisible(true);
  44.         frame.setResizable(false);
  45.         frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  46.         frame.setBounds(d.width/2 - width/2, d.height/2 - height/2, width, height);
  47.  
  48.         frame.add(new MyPanel());
  49.     }
  50. }