Simple Key Events Java source code
#1

Code:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class KeyEvents extends Applet
                        implements KeyListener
{
        String msg = " ";
        int x = 10, y = 20 ;
        public void init()
        {
                addKeyListener(this);
                requestFocus();
        }
        public void KeyPressed(KeyEvent ke)
        {
                showStatus("Key Down");
                int key = ke.getKeycode();
                switch(key)
                {
                        case KeyEvent.VK_F1:
                                msg += "<F1>";
                        case KeyEvent.VK_F2:
                                msg += "<F2>";
                        case KeyEvent.VK_F3:
                                msg += "<F3>";
                        case KeyEvent.VK_PAGE_DOWN:
                                msg += "<PgDn>";
                        case KeyEvent.VK_PAGE_UP:
                                msg += "<PgUp>";
                        case KeyEvent.VK_LEFT:
                                msg += "<Left Arrow>";
                        case KeyEvent.VK_RIGHT:
                                msg += "<Right Arrow>";
                        break;
                }
                repaint();
        }
        }
        public void KeyReleased(KeyEvent ke)
        {
                showStatus("Key Up");
        }
        public void KeyTyped(KeyEvent ke)
        {
                msg += ke.getKeyChar();
                repaint();
        }
        public void paint(Graphics g)
        {
                g.drawString(msg,x,y);
        }
}
Reply
#2
(30-08-2011, 12:43 PM)smart paper boy Wrote:
Code:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class KeyEvents extends Applet
                       implements KeyListener
{
       String msg = " ";
       int x = 10, y = 20 ;
       public void init()
       {
               addKeyListener(this);
               requestFocus();
       }
       public void KeyPressed(KeyEvent ke)
       {
               showStatus("Key Down");
               int key = ke.getKeycode();
               switch(key)
               {
                       case KeyEvent.VK_F1:
                               msg += "<F1>";
                       case KeyEvent.VK_F2:
                               msg += "<F2>";
                       case KeyEvent.VK_F3:
                               msg += "<F3>";
                       case KeyEvent.VK_PAGE_DOWN:
                               msg += "<PgDn>";
                       case KeyEvent.VK_PAGE_UP:
                               msg += "<PgUp>";
                       case KeyEvent.VK_LEFT:
                               msg += "<Left Arrow>";
                       case KeyEvent.VK_RIGHT:
                               msg += "<Right Arrow>";
                       break;
               }
               repaint();
       }
       }
       public void KeyReleased(KeyEvent ke)
       {
               showStatus("Key Up");
       }
       public void KeyTyped(KeyEvent ke)
       {
               msg += ke.getKeyChar();
               repaint();
       }
       public void paint(Graphics g)
       {
               g.drawString(msg,x,y);
       }
}


       
Reply
#3
Angry REY LAFOOT Big Grin 7 ERRORS CHECK REY. UR LIEING.
REY INKOSARI ILLA THAPU CODE PEDETE SAVAGODATHA NAYALA
Angry Angry Angry Angry Angry Angry
Reply
#4
Angry REY LAFOOT Big Grin 7 ERRORS CHECK REY. UR LIEING.
REY INKOSARI ILLA THAPU CODE PEDETE SAVAGODATHA NAYALA
Angry Angry Angry Angry Angry Angry
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: simple udp source code in javanswers in microcontroller in pdfe in java, author events from columbia university, simple projet in java, college events web templates, technology current events, powered by phpbb science current events, events management gmu,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  Window Events Java source code smart paper boy 1 3,673 02-03-2012, 10:48 AM
Last Post: seminar paper
  Inter net banking java source code smart paper boy 3 5,948 01-03-2012, 11:24 AM
Last Post: seminar paper
  UDP server java source code smart paper boy 1 3,812 05-01-2012, 05:50 PM
Last Post: jeslinapeter
  UDP client Java source code smart paper boy 2 3,677 12-12-2011, 09:56 AM
Last Post: seminar addict
  Text Demo Java source code smart paper boy 0 2,076 30-08-2011, 12:44 PM
Last Post: smart paper boy
  Text Area Demo Java source code smart paper boy 0 2,083 30-08-2011, 12:44 PM
Last Post: smart paper boy
  Servlet Database Java source code smart paper boy 0 2,457 30-08-2011, 12:42 PM
Last Post: smart paper boy
  server test Java source code smart paper boy 0 2,261 30-08-2011, 12:42 PM
Last Post: smart paper boy
  Ser To App java source code smart paper boy 0 1,677 30-08-2011, 12:39 PM
Last Post: smart paper boy
  SB Demo java source code smart paper boy 0 1,538 30-08-2011, 12:38 PM
Last Post: smart paper boy

Forum Jump: