Wtk supports Touch Screen Settings

Source: Internet
Author: User

In the/wtk22/wtklib/devices/defaultcolorphone. properties file under the wtk directory, change touch_screen = false to true. Enablealphachannel = true indicates whether the alpha channel is supported.

Midp2.0 has three touch screen methods:

1. pointerdragged (int x, int y) touch screen drag event (not studied yet)
2. pointerpressed (int x, int y) Touch Screen Press
3. pointerreleased (int x, int y) Touch Screen release
Pointerpressed (int x, int y) the method x is automatically called when the user presses the touch screen. Y is the coordinate of the current press.
Pointerreleased (int x, int y) and pointerpressed (int x, int y) are similar to the corresponding touch screen release events.

Import javax. microedition. lcdui. canvas; <br/> Import javax. microedition. lcdui. graphics; </P> <p> public class testpointcanvas extends canvas {</P> <p> Private Static int RX, Ry; </P> <p> protected void paint (Graphics g) {<br/> G. setcolor (1, 255,255,255); <br/> G. fillrect (0, 0,240,320); <br/> G. setcolor (0, 0, 0); <br/> G. drawstring ("this is a touch test! ", 60,100, 20); <br/> G. drawstring ("Left:" + RX, 20,260, 20); <br/> G. drawstring ("Right:" + ry, 180,260, 20); <br/>}</P> <p> protected void pointerpressed (int x, int y) {<br/> If (x <40 & Y> 240) {<br/> docommandl (); <br/>}< br/> If (x> 200 & Y> 240) {<br/> docommandroid (); <br/>}< br/> repaint (); <br/>}</P> <p> protected void keypressed (INT key) {<br/> If (Key =-6) {<br/> docommandl (); <br/>}< br/> If (Key =-7) {<br/> docommandroid (); <br/>}< br/> repaint (); <br/>}</P> <p> private void docommandl () {<br/> RX ++; <br/>}</P> <p> private void docommandroid () {<br/> ry ++; <br/>}< br/><textarea cols="79" rows="15" name="code" class="java">Import javax. microedition. lcdui. display; <br/> Import javax. microedition. MIDlet. MIDlet; <br/> Import javax. microedition. MIDlet. midletstatechangeexception; </P> <p> public class mymidlet extends MIDlet {</P> <p> Public mymidlet () {<br/>}</P> <p> protected void destroyapp (Boolean flag) throws midletstatechangeexception {<br/>}</P> <p> protected void pauseapp () {<br/>}</P> <p> protected void Startapp () throws midletstatechangeexception {<br/> display. getdisplay (this ). setcurrent (New testpointcanvas (); <br/>}</P> <p>}</textarea>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.