JPen是一个用来访问笔触式、触摸屏等接触式设备的Java类库。
示例代码:
import javax.swing.JFrame;import javax.swing.JLabel;import jpen.demo.StatusReport;import jpen.event.PenListener;import jpen.PButtonEvent;import jpen.PenManager;import jpen.PKindEvent;import jpen.PLevelEvent;import jpen.PScrollEvent;public class JPenExampleimplements PenListener{public static void main(String... args) throws Throwable{new JPenExample();}JPenExample(){JLabel l=new JLabel("Move the pen or mouse over me!");PenManager pm=new PenManager(l);System.out.println(new StatusReport(pm));pm.pen.addListener(this);JFrame f=new JFrame("JPen Example");f.getContentPane().add(l);f.setSize(300, 300);f.setVisible(true);}//@Overridepublic void penButtonEvent(PButtonEvent ev) {System.out.println(ev);}//@Overridepublic void penKindEvent(PKindEvent ev) {System.out.println(ev);}//@Overridepublic void penLevelEvent(PLevelEvent ev) {System.out.println(ev);}//@Overridepublic void penScrollEvent(PScrollEvent ev) {System.out.println(ev);}//@Overridepublic void penTock(long availableMillis) {System.out.println("TOCK - available period fraction: "+availableMillis);}}
评论