Solved

Java 1.0.2 keyDown event handling

Posted on 1997-07-03
1
248 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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
String array comparison 4 45
CSV file parsing thru Java 13 39
Cisco ASA: Java web start no go, asdm launcher no go 3 58
restrict decimal places for double datatype 10 31
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

749 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