You Are Here:

Community: Developer Discussion Boards

#1 Old how to focus on my windows when add KeyListener - 2002-05-18, 19:09

Join Date: Mar 2003
Posts: 4
Lu_wenhui
Offline
Registered User
Dear Sir,
I use PersonalJava and Nokia SDK 1.1 emulator to test my program.
First, I define a class which extends CFrame and implements CBAListener, Runnable, KeyListener.
Second, I add Keylistener (add.KeyListener(this))in the constuctor of the class and overload the keyPressed(),keyReleased(),keyTyped().
Result, CBAlistener works fine but Keylistener does not work, Moreover, if I use mouse the click the top of the windows of my application. the KeyListener begin to work. I think it should be something related to focus event but I dont know how to handle it.
Please help me.
Code related:

public class Music extends CFrame implements Runnable, KeyListener , CBAListener
{
CBAHandler cba;
public static void main( String args[] )
{
new Music();
}

public Music()
{

cba = new CBAHandler( this );
cba.setText( ADD , "Add " );
cba.setText( CLOSE , "Close" );
cba.activate();
addKeyListener(this);
item.addKeyListener(this);
add(item);/*item is a object extends Canvas*/
show();
}
public void keyPressed(KeyEvent ke){....}
public void keyReleased(KeyEvent ke){....}
public void keyTyped(KeyEvent ke){}
......
}

#2 Old RE: how to focus on my windows when add KeyListener - 2002-06-05, 17:50

Join Date: Mar 2003
Posts: 4
Lu_wenhui
Offline
Registered User
add the sentence like that in the constructor of Music
....
this.requestFocus();
....
  « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d5632X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZjavaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxjavaX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ