⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spstimerpanel.java

📁 打印管理程序,测试完全通过.windows开发环境.
💻 JAVA
字号:
package jp.co.ntl.swing.ext;

import java.util.Timer;
import java.util.TimerTask;

import javax.swing.JFrame;
import javax.swing.JApplet;

import jp.co.ntl.Net;
import jp.co.ntl.NetworkException;
import jp.co.ntl.ServerException;
import jp.co.ntl.TimeOutException;
import jp.co.ntl.Util;
import jp.co.ntl.ext.SPSJNI;
import jp.co.ntl.swing.BasePanel;

public abstract class SPSTimerPanel extends BasePanel {
	private Timer		timer = null;
	private SPSTimerTask	timerTask = null;
	
	public SPSTimerPanel() {
	}
	
	public SPSTimerPanel(JFrame parent, Net net) {
		super(parent, net);
	}
	
	public SPSTimerPanel(JApplet apl, Net net) {
		super(apl, net);
	}
	
	public void startTimer(int initTimerValue, int delay, int period) {
		//SPSJNI.registerHookEvent();
		timer = new Timer(true);
		timerTask = new SPSTimerTask(initTimerValue);
		timer.schedule(timerTask, delay, period);	// 偲傝偁偊偢僐儊儞僩傾僂僩
	}
	
	public void cancelTimer() {
		if (timer != null) {
			timer.cancel();
		}
		//SPSJNI.unregisterHookEvent();
	}
	
	public int getTimerValue() {
		return timerTask.getTimerValue();
	}
	
	public void setTimerValue(int timerValue) {
		timerTask.setTimerValue(timerValue);
	}
	
	public void resetTimerValue() {
		timerTask.resetTimerValue();
	}
	
	private class SPSTimerTask extends TimerTask {
		private int	timerValue;
		private int	initTimerValue;

		public SPSTimerTask(int initTimerValue) {
			super();
			this.initTimerValue = initTimerValue;
			this.timerValue = initTimerValue;
		}
		
		public void run() {
			Util.debugPrint("timerValue = " + timerValue);
			if (timerValue <= 0) {
				timeOutFunc();
				cancel();
			} else {
				timerValue--;				
/*				if (SPSJNI.isDetectedHookEvent()) {
					// KeyDown丄MouseDown僀儀儞僩偑偁偭偨偲偒僙僢僔儑儞僞僀儅乕傪儕僙僢僩偡傞
					Util.debugPrint("Detect key down or mouse down event");
					resetTimerValue();
				} else {
					timerValue--;
				}
*/			}
		}
		
		public int getTimerValue() {
			return timerValue;
		}
		
		public void setTimerValue(int timerValue) {
			this.timerValue = timerValue;
		}
		
		public void resetTimerValue() {
			timerValue = initTimerValue;
		}
	}
	
	protected abstract void timeOutFunc();
	public abstract void beginPanel() throws NetworkException, ServerException, TimeOutException;
	protected abstract void buildComponents();
	protected abstract boolean doDelete() throws NetworkException, ServerException, TimeOutException;
	protected abstract boolean doModify() throws NetworkException, ServerException, TimeOutException;
	protected abstract boolean doRegister() throws NetworkException, ServerException, TimeOutException;
	public abstract int getInfosFromServer();
	protected abstract void setPopupMenuState();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -