public void openCaptureWindow() { if (framenr - lastcapture_framenr < number_of_frames_before_cwopen) { return; } // Capture Window cw.setVisible(true); cw.toFront(); // Timer for closing the capturewindow TimerTask task = new TimerTask() { @Override public void run() { EventQueue.invokeLater( new Runnable() { public void run() { System.out.println("Closing cw..."); cw.setVisible(false); cwText.setText(""); // Empty text in case there is a text } }); } }; cwTimer = new Timer(); cwTimer.schedule(task, number_of_second_capturewindow * 1000); }
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); }