/** * Creates preview for the device(video) in the video container. * * @param device the device * @param videoContainer the container * @throws IOException a problem accessing the device. * @throws MediaException a problem getting preview. */ private static void createPreview(MediaDevice device, final JComponent videoContainer) throws IOException, MediaException { videoContainer.removeAll(); videoContainer.revalidate(); videoContainer.repaint(); if (device == null) return; Component c = (Component) GuiActivator.getMediaService() .getVideoPreviewComponent( device, videoContainer.getSize().width, videoContainer.getSize().height); videoContainer.add(c); }
/* * Create a BufferedImage for Swing components. * The entire component will be captured to an image. * * @param component Swing component to create image from * @param fileName name of file to be created or null * @return image the image for the given region * @exception IOException if an error occurs during writing */ public static BufferedImage createImage(JComponent component, String fileName) throws IOException { Dimension d = component.getSize(); if (d.width == 0) { d = component.getPreferredSize(); component.setSize(d); } Rectangle region = new Rectangle(0, 0, d.width, d.height); return ScreenCapture.createImage(component, region, fileName); }