Exemple #1
0
  // ekran görüntüsü al.
  public static BufferedImage screenShotGetir() throws AWTException {
    /*
     * http://www.arulraj.net/2010/06/print-screen-using-java.html
     */

    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension dim = tk.getScreenSize();
    Rectangle rect = new Rectangle(dim);
    Robot myRobot = new Robot();

    BufferedImage myBufferedImage = myRobot.createScreenCapture(rect);
    return myBufferedImage;
  }
  public static void main(String s[]) {

    // Getting save directory
    String saveDir;
    if (s.length > 0) {
      saveDir = s[0];
    } else {
      saveDir =
          JOptionPane.showInputDialog(
              null,
              "Please enter directory where "
                  + "the images is/will be saved\n\n"
                  + "Also possible to specifiy as argument 1 when "
                  + "running this program.",
              "l:\\webcamtest");
    }

    String layout = "";
    if (s.length > 1) {
      layout = s[1];
    }

    // Move mouse to the point 5000,5000 px (out of the screen)
    Robot rob;
    try {
      rob = new Robot();
      rob.setAutoDelay(500); // 0,5 s
      rob.mouseMove(5000, 5000);
    } catch (AWTException e) {
      e.printStackTrace();
    }

    // Make the main window
    JFrame frame = new JFrame();
    frame.setAlwaysOnTop(true);
    frame.setTitle(
        "Webcam capture and imagefading - "
            + "Vitenfabrikken Jærmuseet - "
            + "made by Hallvard Nygård - "
            + "Vitenfabrikken.no / Jaermuseet.no");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setUndecorated(true);

    WebcamCaptureAndFadePanel panel = new WebcamCaptureAndFadePanel(saveDir, layout);
    frame.getContentPane().add(panel);
    frame.addKeyListener(panel);
    frame.pack();

    frame.setVisible(true);
  }
Exemple #3
0
  // We need in this constructor to pass frame position between JVMs
  public FileListBetweenJVMsTest(
      Point targetFrameLocation, Point dragSourcePoint, int transferredFilesNumber)
      throws InterruptedException {
    TargetFileListFrame targetFrame =
        new TargetFileListFrame(targetFrameLocation, transferredFilesNumber);

    Util.waitForIdle(null);

    final Robot robot = Util.createRobot();

    robot.mouseMove((int) dragSourcePoint.getX(), (int) dragSourcePoint.getY());
    sleep(100);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    sleep(100);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    sleep(100);

    Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(), InputEvent.BUTTON1_MASK);
  }
  /**
   * Starts the program
   *
   * @param args the standard arguments. If "competition" is one of them, then the SmartDashboard
   *     will be in competition mode
   * @see main#inCompetition() inCompetition()
   */
  public static void main(final String[] args) {
    // Present a loading bar (it will only show up if this is going slowly)
    final ProgressMonitor monitor =
        new ProgressMonitor(
            null, "Loading SmartDashboard", "Initializing internal code...", 0, 1000);

    // Search the filesystem for extensions (49%)
    FileSniffer.findExtensions(monitor, 0, 490);

    ArgParser argParser = new ArgParser(args, true, true, new String[] {"ip"});
    inCompetition = argParser.hasFlag("competition");
    boolean customIP = false;
    if (argParser.hasValue("ip")) {
      Robot.setHost(argParser.getValue("ip"));
      customIP = true;
    }

    final boolean useTeamNumber = !customIP;
    try {
      SwingUtilities.invokeAndWait(
          new Runnable() {

            public void run() {
              try {

                monitor.setProgress(500);
                monitor.setNote("Setting Theme");
                try {
                  for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                      UIManager.setLookAndFeel(info.getClassName());
                    }
                  }
                } catch (Exception e) {
                }

                // Initialize GUI
                DashboardFrame frame = new DashboardFrame(inCompetition);

                monitor.setProgress(600);
                monitor.setNote("Getting Team Number");
                IntegerProperty team = frame.getPrefs().team;
                while (team.getValue() <= 0) {
                  team.setValue(JOptionPane.showInputDialog("Input Team Number"));
                }
                if (useTeamNumber) {
                  Robot.setTeam(frame.getPrefs().team.getValue());
                }

                frame.pack();
                frame.setVisible(true);

                monitor.setProgress(750);
                monitor.setNote("Loading From Save");

                // Load
                File file = new File(frame.getPrefs().saveFile.getValue());
                if (file.exists()) {
                  frame.load(file.getPath());
                }

                monitor.setProgress(1000);

              } catch (Exception e) {
                e.printStackTrace();

                System.exit(1);
              }
            }
          });
    } catch (Exception ex) {
      ex.printStackTrace();
      System.exit(2);
    }
  }