JOptionPane for Errors, general refactoring, deprecated class removed (CameraRenderer) moved into Swing now

modified:
/ SwingCCTVManager ; Error Pane, refactoring
/ WebcamCaptureLoop ; cleanup method for closing cameras reliably, and some MessageDialogs for error handling (just fails lol)
/ SwingCameraWindow ; refactor some legacy code into a "modern" lambda function , Message Dialog for error handling , and some g2d stuff (paintComponent)

removed:
- CameraRenderer.java ; Deprecated Component, was used for SWT GL Surfaces. We dont do that now!

---

rattatwinko
This commit is contained in:
2026-01-13 17:33:47 +01:00
parent 370df03205
commit b767ba27b3
4 changed files with 50 additions and 119 deletions

View File

@@ -1,9 +1,12 @@
package io.swtc.proccessing;
import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamException;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.util.function.Consumer;
import javax.swing.JOptionPane;
public class WebcamCaptureLoop {
private final Webcam webcam;
@@ -46,15 +49,39 @@ public class WebcamCaptureLoop {
}
try {
webcam.close();
} catch (IllegalStateException e) {
e.printStackTrace();
// show a error message from javax.swing.awt.JOptionPane
JOptionPane.showMessageDialog(
null,
"IllegalStateException@"+e,
"IllegalStateException",
JOptionPane.ERROR_MESSAGE
);
}
});
captureThread.setName("cam_cap_thread");
captureThread.start();
}
// method for cleaning up
private synchronized void cleanup() {
try {
// if the camera is open try to cloes it!
webcam.close();
} catch (WebcamException exception) {
JOptionPane.showMessageDialog(
null,
"Cleanup failed \nWebCamException@"+exception.getMessage(),
"WebCamException",
JOptionPane.ERROR_MESSAGE
);
}
}
public void stop() {
running = false;
cleanup();
}
}