Skip to content

Commit

Permalink
Add stop button in TakeSnaphotFromVideoExample, refs #188
Browse files Browse the repository at this point in the history
  • Loading branch information
sarxos committed Mar 10, 2014
1 parent eff0c3d commit 7bfe979
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions webcam-capture/src/example/java/TakeSnapshotFromVideoExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,34 @@ public void actionPerformed(ActionEvent e) {

@Override
public void run() {

btStop.setEnabled(true);

for (WebcamPanel panel : panels) {
panel.start();
}
}
}

private class StopAction extends AbstractAction {

public StopAction() {
super("Stop");
}

@Override
public void actionPerformed(ActionEvent e) {

btStart.setEnabled(true);
btSnapMe.setEnabled(false);
btStop.setEnabled(false);

for (WebcamPanel panel : panels) {
panel.stop();
}
}
}

private Executor executor = Executors.newSingleThreadExecutor();

private Dimension size = WebcamResolution.QQVGA.getSize();
Expand All @@ -79,6 +101,7 @@ public void run() {

private JButton btSnapMe = new JButton(new SnapMeAction());
private JButton btStart = new JButton(new StartAction());
private JButton btStop = new JButton(new StopAction());

public TakeSnapshotFromVideoExample() {

Expand All @@ -96,6 +119,7 @@ public TakeSnapshotFromVideoExample() {
// webcam is started

btSnapMe.setEnabled(false);
btStop.setEnabled(false);

setLayout(new FlowLayout());

Expand All @@ -105,6 +129,7 @@ public TakeSnapshotFromVideoExample() {

add(btSnapMe);
add(btStart);
add(btStop);

pack();
setVisible(true);
Expand Down

0 comments on commit 7bfe979

Please sign in to comment.