Solved

Java 1.0.2 keyDown event handling

Posted on 1997-07-03
1
238 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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
changeXy challenge 13 56
Updating Java 9 86
get weblogic logged in user in java 2 39
eclipse java  build path 6 17
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now