Solved

Java 1.0.2 keyDown event handling

Posted on 1997-07-03
1
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

688 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