Пример #1
0
  /**
   * The main method.
   *
   * @param args the arguments
   */
  public static void main(String[] args) {

    System.out.println("Please input demo running time (in seconds) of each thread.");
    Scanner sc = new Scanner(System.in);
    int runningDuration = sc.nextInt();
    sc.close();

    long startTime = System.currentTimeMillis();
    System.out.println(
        new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()) + " Demo Start!");

    // Initialize log file
    try {
      File f = new File("demo_log.txt");
      if (!f.exists()) f.createNewFile();
    } catch (IOException e) {
      e.getMessage();
    }

    for (int i = 0; i < 10; i++) {

      Demo demo = new Demo(i + 1);
      demo.setRunningTime(runningDuration);
      Thread thread = new Thread(demo);
      threadList.add(thread);

      thread.start();
      String activity =
          new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date())
              + " Demo Thread "
              + (i + 1)
              + " Start running!";
      log(activity);
      System.out.println(activity);
    }

    try {
      Thread.sleep(1000);

      for (Thread t : threadList) {
        t.join();
      }

    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    long endTime = System.currentTimeMillis();
    System.out.println(
        new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date())
            + " Demo stop! Total demo time "
            + ((endTime - startTime) / 1000)
            + "s");
  }
 private JideTabbedPane createTabbedPane(Demo demo) {
   _pane = new JideTabbedPane();
   _demoPanel = demo.getDemoPanel();
   _pane.addTab("Demo", new JideScrollPane(new DemoPanel(_demoPanel)));
   _pane.setTabShape(JideTabbedPane.SHAPE_BOX);
   _pane.setHideOneTab(true);
   _pane.setFocusable(false);
   _pane.setTabPlacement(JideTabbedPane.TOP);
   return _pane;
 }
 public void browseSourceCode() {
   if (_pane.getTabCount() == 1) {
     _pane.addTab("Source", AbstractDemo.createSourceCodePanel(_demo.getDemoSource()));
   }
   _pane.setSelectedIndex(1);
 }
 public DemoDocumentComponent(Demo demo) {
   super(null, demo.getName(), demo.getName(), DemoCellRenderer.getProductIcon(demo.getProduct()));
   setComponent(createTabbedPane(demo));
   _demo = demo;
 }