Solved

Java 1.0.2 keyDown event handling

Posted on 1997-07-03
1
247 Views
Last Modified: 2008-03-06
I need to catch a <Alt>+S key press in a TextArea using the 1.0.2 event model.

a) can I do this with out subclassing the TextArea and

b) if I can how do I, some example code would be great

thanks
0
Comment
Question by:Timothy070397
1 Comment
 
LVL 2

Accepted Solution

by:
mgk earned 50 total points
ID: 1222644
Try this out:

import java.applet.*;
import java.awt.*;

public class test extends Applet{
   TextArea t;
      
   public void init(){
      t=new TextArea();
      this.setLayout(new BorderLayout());
      this.add("Center",t);
   }
      
   public boolean keyDown(Event e, int key){
      if ((e.modifiers&Event.ALT_MASK)!=0) {
         System.out.println("<ALT>"+(char)e.key);
      }
      else {
         t.appendText(String.valueOf((char)e.key));
      }
      return true;
   }
}
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question