com.github.sarxos.webcam.WebcamPickerModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webcam-capture Show documentation
Show all versions of webcam-capture Show documentation
This library allows you to use your PC webcam, IP or network cameras directly from Java. It's compatible with most operating systems (Windows, Linux, MacOS).
The newest version!
package com.github.sarxos.webcam;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
public class WebcamPickerModel extends DefaultComboBoxModel {
private static final long serialVersionUID = 1L;
public WebcamPickerModel(List webcams) {
super(webcams.toArray(new Webcam[webcams.size()]));
}
@Override
public Webcam getSelectedItem() {
return (Webcam) super.getSelectedItem();
}
@Override
public void setSelectedItem(Object webcam) {
if (!(webcam instanceof Webcam)) {
throw new IllegalArgumentException("Selected object has to be an Webcam instance");
}
super.setSelectedItem(webcam);
}
}