- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
- import java.awt.*;
- import java.applet.*;
- import java.net.*;
- public class easyCam extends Applet {
- private Image myImage = null;
- private int startIndex = 1;
- private int endIndex = 9;
- private int currentIndex;
- private int sleepTime = 500;
- private String fileBase;
- private String fileExtension;
- private Thread timerThread;
- private volatile boolean noStopRequested;
- private MediaTracker tracker;
- public void init() {
- tracker = new MediaTracker(this);
- String strStartIndex = getParameter("STARTINDEX");
- String strEndIndex = getParameter("ENDINDEX");
- String strSleepTime = getParameter("MSDELAY");
- fileBase = getParameter("FILEBASE");
- fileExtension = getParameter("FILEEXT");
- if (strStartIndex != null)
- startIndex = Integer.parseInt(strStartIndex);
- if (strEndIndex != null)
- endIndex = Integer.parseInt(strEndIndex);
- if (strSleepTime != null)
- sleepTime = Integer.parseInt(strSleepTime);
- startThread();
- }
- private void startThread() {
- noStopRequested = true;
- Runnable r = new Runnable() {
- public void run() {
- runWork();
- }
- };
- timerThread = new Thread(r, "Timer");
- timerThread.start();
- }
- private void stopThread() {
- noStopRequested = false;
- timerThread.interrupt();
- }
- private void runWork() {
- currentIndex = startIndex;
- boolean imageload = false;
- try {
- while ( noStopRequested ) {
- currentIndex = currentIndex + 1;
- if( currentIndex > endIndex )
- currentIndex = startIndex;
- if( imageload == true ) {
- tracker.removeImage(myImage);
- myImage.flush();
- myImage = null;
- }
- myImage = getImage(getDocumentBase(), fileBase + Integer.toString(currentIndex) + fileExtension);
- tracker.addImage(myImage, 0);
- tracker.waitForAll();
- imageload = true;
- repaint();
- Thread.sleep( sleepTime );
- }
- } catch ( InterruptedException x ) {
- Thread.currentThread().interrupt();
- }
- }
- public void paint(Graphics g) {
- update(g);
- }
- public void update(Graphics g) {
- if( myImage != null ) {
- g.drawImage(myImage, 0, 0, this);
- }
- }
- public void destroy() {
- stopThread();
- myImage.flush();
- myImage = null;
- }
- }