JPen接触式设备访问库
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 JPenExample implements 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); } //@Override public void penButtonEvent(PButtonEvent ev) { System.out.println(ev); } //@Override public void penKindEvent(PKindEvent ev) { System.out.println(ev); } //@Override public void penLevelEvent(PLevelEvent ev) { System.out.println(ev); } //@Override public void penScrollEvent(PScrollEvent ev) { System.out.println(ev); } //@Override public void penTock(long availableMillis) { System.out.println("TOCK - available period fraction: "+availableMillis); } }
评论