KeyCode always zero

Hi all.
I'm trying to get my JTextField to transfer focus when the user hits enter. However, for some reason, I always get zero when I call keyEvent.getKeyCode(). The weird thing is, the getKeyChar() shows the correct character. Something funky is going on.
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class MyCustomTextField extends JTextField {
     protected void processKeyEvent(KeyEvent e) {
          if (e.getID() == KeyEvent.KEY_TYPED) {
               System.out.println(
                    "TYPED IN PROCESSKEYEVENT: " + e.getKeyChar() + " " + e.getKeyCode());
               if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                    transferFocus();
          super.processKeyEvent(e);
     public MyCustomTextField() {
          super();
          setColumns(10);
          addKeyListener(new KeyAdapter() {
               public void keyTyped(KeyEvent e) {
                    System.out.println(
                         "TYPED IN KEYADADPTER: " + e.getKeyChar() + " " + e.getKeyCode());
                    super.keyTyped(e);
     public static void main(String[] args) {
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().setLayout(
               new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
          JPanel panel = new JPanel();
          panel.add(new MyCustomTextField());
          panel.add(new MyComboBox());
          frame.getContentPane().add(panel);
          panel = new JPanel();
          panel.add(new MyCustomTextField());
          panel.add(new MyComboBox());
          frame.getContentPane().add(panel);
          frame.pack();
          frame.show();
class MyComboBox extends JComboBox {
     MyComboBox() {
          super(new String[] { "Cool", "Not Cool" });
     public void processKeyEvent(KeyEvent e) {
          if (e.getID() == KeyEvent.KEY_TYPED) {
               System.out.println(
                    "TYPED: " + e.getKeyChar() + " " + e.getKeyCode());
               if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                    transferFocus();
          super.processKeyEvent(e);
}output-> First letter is character typed, next letter is keycode of the character.
TYPED IN PROCESSKEYEVENT: a 0
TYPED IN KEYADADPTER: a 0
TYPED IN PROCESSKEYEVENT: s 0
TYPED IN KEYADADPTER: s 0
TYPED IN PROCESSKEYEVENT: d 0
TYPED IN KEYADADPTER: d 0
TYPED IN PROCESSKEYEVENT: f 0
TYPED IN KEYADADPTER: f 0

Works OK changing
if (e.getID() == KeyEvent.KEY_TYPED) {
to
if (e.getID() == KeyEvent.KEY_PRESSED) {
and
public void keyTyped(KeyEvent e) {
to
public void keyPressed(KeyEvent e) {                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Reference point locater missing, x and y always zero

    Hey,
    I don't know how it happened, but it sure did and its making me crazy! My reference point locater is nonfunctioning. The x and y axis points are always zero. Knowing what happened would be fine but knowing how to fix it would be a miracle! Anybody?

    Cindy,
    One of the first things to try is to Move the folder, see instructions and explanations here: http://www.bugge.com/Family-and-friends/Illy/illy.html

  • Popularity trends report always zero

    I am migrating serveral site collections from SP2010 to SP2013 farm. After migrated the sites, I enabled "Reporting" feature in site collection feature list.
    I found the usage report is always zero and after some research I performed the check suggested here:
    http://geekswithblogs.net/bjackett/archive/2013/08/26/powershell-script-to-workaround-no-data-in-sharepoint-2013-usage.aspx
    I found the Receivers are not well defined. After running the powershell script suggested I am able to define the Receivers.
    However, after 24 hours, all the reports still show zero. What else I can check? Thank you!

    Hi Mark,
    As I understand, usage report shows empty in your site collection. So far, you have confirmed the related two timer jobs work well as Inderjeet suggested, and defined new receivers as the blog you posted.
    Below are the tips you should take into consideration when testing the issue:
    1. Site we want to get web analytics report of should be in the content source.
    2. Site should be accessed by normal users; site accessed by farm admin users will be ignored by web analytics.
    3. Site should be accessed from client machines; site accessed with in server will be ignored by web analytics.
    4. System pages like pages under _layouts, _catalogs and web service calls are ignored web analytics.
    5. Also give at least 1 day to see data in usage report after you have accessed site.
    Below are the suggestions you could check:
    1.Confirm timer service is running, search service works well and run a full crawl for the site collection.
    2.Ensure the account for Usage and Health Data collection has enough permission.
    http://technet.microsoft.com/en-us/library/ee663480(v=office.15).aspx
    Regards,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected] .
    Rebecca Tu
    TechNet Community Support

  • Confirmed qty is always zero..

    Hi all,
    I am testing the Consignment Process in SD.
    I have done the below settings in IMG.  But when I create the Consign Fillup Order, always the "Availability Control Screen" pops with the Confirmed qty showing always ZERO....even though the plant has sufficient stock.
    When I create Normal Sales Order, I don't get this message. Is't becos in Schedule Line cate CP the Av check is not ticked in t-code : VOV6 for movement type 601 ???
    1. Consignment fill up:
    Sales document type is KB
    Item category KBN
    shedule line category E1
    In this step, since we are not invoicing the customer. document flow is sales order -
    delivery item category. It will not be relevent for billing and pricing because we are not charging money for these goods in this step.
    In schedule line category, we will set movement type 631 & set for availability check and TOR.
    2. Consignment Issue.
    Once the customer informed us that he used all the goods or partial goods then we will create consignment issue for used goods.
    Sales document: KE
    Item category: KEN
    shedule line category: C0 or C1
    Here we are invoicing the customer(because he used the goods). We assign the delivery documnt and billing document to the sales document.
    In item category, we are setting relevent for billing, pricing, special stock.
    In schedule line category, the setting is 633 movement type, relevent for availability check & TOR.
    3. Consignment Return: Customer found that some goods are damaged or he not able to sold the goods he want to send it back. that we are creating this document.
    Sales document type: KR
    Item category: KRN
    Shedule line category: D0
    Then I assigned delivery document and billing to sales document. We create return order, return delivery, return billing.
    The setting for item category is relevent for billing, returns, pricing, special stock.
    The setting for schedule line item category: 634 movement type, NO availability NO TOR.
    4. Consignment Pick up:
    Even if we create the consignment return the goods are not coming directly  to our plant. For that we need to create consignment pick up. here the owner ship is not changing so we do not need to create billing.
    Assign retrun delivery to sales document type.
    Sales document: KA
    Item category: KAN
    schedule line category: F0 & F1
    The item category is relevent for returns. any shedule line category relevent for 632 movement type, MRP, availability check, delivery.
    Regards,
    Pri

    Dear Anne
    My suggestion would be create the issue order with reference to proforma (F8).  Then only, you have the track record of whatever material despatches from plant tallies with material available in issue order.
    If you create  issue order with reference to fill up order, at a later stage, you will not be able to track despatch details accurately.
    To explain your requirement in detail, my comments would be as follows:-
    You created Consignment fillup order for x1 material 10 pcs.  For this you create fillup delivery and proforma invoice.  Based on this proforma invoice, you create an issue order so that whatever you transfer the stock to warehouse, for that quantity only, you issue order will show the details.
    Against this issue order, you create a issue delivery for 10 pcs and generate commercial invoice (F2) for the same.  Now as you said, if end customer rejects 2 pcs out of 10 pcs, you create a return order with reference to commercial invoice.  It should NOT be with reference to issue order.
    I am sure, now your flow will be in line with the standard process.
    Thanks
    G. Lakshmipathi
    ps:-  think you took most of my today's time ::).  no problem in turn, I am also checking my capability in this process.  reward if this really useful

  • KeyCode always returns 0.

    no matter what i tried to do the keyCode always returns 0 :( .
    import java.awt.*;
    import javax.swing.*;
    import java.applet.Applet;
    import java.applet.*;
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import java.util.Random;
    public class Tic extends Applet implements KeyListener
         int currentLine=30;
         char typ = '1';
         public void init()
         addKeyListener(this);
          TextField tf = new TextField(20);
             add(tf);
             tf.addKeyListener(this);
          //String styp = typ.toString;
         //page.drawString(typ, 10, currentLine);
         public void keyPressed(KeyEvent e)
         repaint();
         public void keyReleased(KeyEvent e){}
         public void keyTyped(KeyEvent e)
              int keyCode;
              keyCode= e.getKeyCode();
         showStatus(" Recently typed characters are : "+ keyCode);
         public void paint(Graphics g)
         currentLine=currentLine+20;
             public void actionPerformed(ActionEvent e)
                 //ohboy2.loop();//sound
    }

    Sob sob
    it doesnt wannna move!!!!
    import java.awt.*;
    import javax.swing.*;
    import java.applet.Applet;
    import java.applet.*;
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Random;
    public class Tic extends Applet implements KeyListener
         AudioClip cuckoo;
         int keyCode;
         int x = 20;
         int y = 20;
         Image pic = null;
         public void init()
         addKeyListener(this);
              pic = getImage(getDocumentBase(),"Bi.jpg");
              cuckoo = getAudioClip(getDocumentBase(), "cuckoo.wav");
              cuckoo.loop();
         public void keyPressed(KeyEvent e)
              keyCode= e.getKeyCode();
              showStatus(" Recently typed characters are : "+ keyCode);
              if (keyCode==37)
                            x=x+20;
         public void keyReleased(KeyEvent e)
              keyCode= e.getKeyCode();
              showStatus(" Recently typed characters are : "+ keyCode);
              if (keyCode==37)
                            x=x+20;
         public void keyTyped(KeyEvent e)
              keyCode= e.getKeyCode();
              showStatus(" Recently typed characters are : "+ keyCode);
              if (keyCode==37)
                            x=x+20;
          public void paint(Graphics g)
                  g.drawImage(pic,0,0,this);
                  g.drawLine( x,y, x+40,y+40 );
                  if (keyCode==37)
                            x=x+20;
    }

  • IPV6 DHCP : Active Clients always zero 0

    Hello All,
    I have configure IPV6 DHCP by using below mentioned configuration, all my LAN PCs are getting IPV6 correctly and internet is also running well.
    But if run this command on Router, so it shows Active Clients are always zero 0.
    R1# sh ipv6 dhcp pool
    DHCPv6 pool: DHCP_POOL
      DNS server: 2001:470:ab::cd
      Domain name: abc.com
      Active clients: 0
    R1# sh ipv6 dhcp binding --> also show empty result.
    Can anyone please tell me the reason .
    MY CONFIGURATION:
    ipv6 unicast-routing
    ipv6 dhcp pool DHCP_POOL
    dns-server 2001:470:ab::cd
    domain-name abc.com
    interface FastEthernet0/0
    no ip address
    speed 100
    full-duplex
    ipv6 address 2400:FC00:ab::/64 eui-64
    ipv6 nd prefix 2400:FC00:ab::/64
    ipv6 nd other-config-flag
    ipv6 dhcp server DHCP_POOL
    ipv6 route ::/0 2400:FC00:ab::1
    int fa0/0 is directly connected to my LAN Switch.
    Regards,

    Ok , the problem solved by changing the configuration in this way. Now it is showing Active clients and Bindings.
    I will try your method too, to just add ipv6 nd managed-config-flag in my previous config.
    But i am still confused which configuratrion is better and which technique to use ?? 
    My previous config was stateless , is my new config is stateful ??
    My NEW Configuration:
    ipv6 unicast-routing
    ipv6 cef
    ipv6 dhcp pool DHCP_POOL
    address prefix 2400:FC00:ab::/64 lifetime infinite infinite
    link-address 2400:FC00:ab::2/64
    dns-server 2001:470:ab::cd
    domain-name abc.com
    interface FastEthernet1/0
    no ip address
    duplex full
    speed 100
    ipv6 address 2400:FC00:ab::2/64
    ipv6 enable
    ipv6 nd managed-config-flag
    ipv6 dhcp server DHCP_POOL
    ipv6 route ::/0 2400:FC00:ab::1

  • Movieclip's width is always zero

    Hi, I am having some trouble with some Movieclip this time so I come here to ask for help again.  Please see following for my current code, whenever I try detecting the MC's width, it always display zero for some reason.
    On the 2nd frame, the following function will start loading.  After the initial turn, I have another condition statement to check whether it should go to another frame or not.  If it's staying in this frame, it will load this function again, and the temp_counter will increases.
    tel_phrase_holder is just a dynamic textfield I use to display the width only.
    function tel_load () {
        tel_holder.removeChildAt(0);
        var a = new Loader();   
        tel_holder.addChild(a);
        a.load(new URLRequest(tel_pic_start[temp_counter - 1]));
        tel_phrase_holder.text = tel_holder.width.toString();
    I tried putting "tel_phrase_holder.text = tel_holder.width.toString();" at the beginning as well like I did at the following code.  It's slightly better, but it's loading the previous picture's width instead of the current picture's width.
    function tel_load () {
       tel_phrase_holder.text = tel_holder.width.toString();
         tel_holder.removeChildAt(0);
         var a = new Loader();   
         tel_holder.addChild(a);
         a.load(new URLRequest(tel_pic_start[temp_counter - 1]));
    Thanks in advance

    When you issue a URLRequest for the loader you have to wait until the content finishes loading and is ready to be accessed before you try and get properties. That is why when you put the code at the beginning you get the results of the "previous" contents, because at that point they aren't previous at all!
    Check out the documentation for the Loader class. Basically you need to do this:
    var a:Loader = new Loader();
    a.contentLoaderInfo.addEventListener(Event.INIT,initHandler)
    function initHandler(e:Event){
         // the content has loaded and is ready
         trace(e.target);
         // do what you need

  • 1099-MISC nonemployee compensation amount always zero in lower part

    Hi,
    When I m trying to execute withholding tax report S_P9C_18000158 ( for 1099-MISC ) for multiple vendor account, the form is not printing Nonemployee compensation for vendor who are getting printed in lower half of form. The same is getting printed for all vendor in upper half.
    Rest all data are getting printed properly in both half.
    The nonemployee compensation amount always shows zero in lower half.
    I doubt if we need some notes or any settings? any inputs would be appreciable
    Thanks
    Pankaj

    Hi Praveen,
    Thanks a lot for the input.
    Yes I tried downloading the file and the amount shows correctly for both upper and lower part.
    Infact I have already checked sapscript form and found in std program the amount in lower form is assigned to bset-fwbase field and sapscript forms prints the value
    in field *bset-fwbase. so its only changing the assignment in td prg.
    But before doing the repair ...I just wanted to know if there is some notes provided for this so that we dont have to touch std code..
    let me know if u r aware of any...
    Thanks
    Pankaj

  • Nast-Anzal(no of copies) is always zero for GR Label

    Hi ,
      I am issuing GR slips.I have choosen "Individual Slip" Print option and I have given "No of GR Slips" as 3 .My requirement is to print Multile GR slips.But its always printing one.I checked the NAST Table entry .I found the Anzal (no of copies)  field of NAST  is zero.Please,let me know the problem.
    Thanks in advance.
    Nuthan.

    Number of GR Slip/Label is being decided from this code, not from the NAST.
    Code snippet which decides the no of copies from program SAPM07DR routine ENTRY_WE01 .
      IF not t159p-xmehr is initial.
        IF mseg-weanz gt 0.
          anzahl = mseg-weanz.
        ELSE.
          anzahl = 1.
        ENDIF.
      ELSE.
        anzahl = 1.
      ENDIF.
    Find out, what do you have in this values.
    Regards,
    Naimesh Patel

  • Step Count always zero?

    Hi,
    Report generation sequence file, like reportgen_txt.seq shipped with TestStand, has step called "add step count". In my understanding it comes from model, like sequential model.seq, but I have always seen it to be zero.
    I was interpretating this parameter in report would tell how many steps a test took in total, because my test execution may take different number of steps. Is my assumption correct that this parameter would tell total number of steps executed, including all step executed e.g. in a while loop ?
    br
    petri
    Solved!
    Go to Solution.

    Thanks Sahana your reply.
    That seems to be true in my machine when I have selected report generator option DLL. But when I have selected sequence option, which I want to use because I have a custom reporter to excel sheet, the step count remains zero. I'm not sure if something has happened with sequences, they are pretty old originally coming from TestStand 3.x. Anybody help to try this ?
    Sequence file attached.
    Attachments:
    add step count to report.seq ‏7 KB

  • Measuring ellapsed time always zero in FlashBuilder 4

    Here is what I have worked out so far:
    I declare some public variables.
        <fx:Script>
            <![CDATA[
                import flash.utils.getTimer;
                import mx.controls.Alert;
                import mx.events.FlexEvent;
                import mx.events.ListEvent;
                public var now: Date = new Date;
                public var beg_tck: uint;
                public var end_tck: uint;
    I then start my app in debug mode.
    I then click a button and load the beg_tck variable:
                protected function btnGo_clickHandler(event:MouseEvent):void
                 beg_tck = now.getTime();
                 ... "hit and stay at debug stop"...
    I go over to the debug screen in FlashBuilder 4 and wait about 3 seconds, then I resume with F8
    I have a updateComplete which loads the end_tck, and displays their contents.
            protected function grdSBJs_updateCompleteHandler(event:FlexEvent):void
                        end_tck = now.getTime();  //  - beg_tck
                        lblResponseTime.text = 'Response time: ' + String((end_tck)) + '  beg_tck: ' + String(beg_tck);                   
    For some reason beg_tck and end_tck are ALWAYS THE SAME.
    Why is this happening?  Even though I've held back processing for 3 seconds, the now.getTime() is putting the exact same number into beg_tck and end_tck.
    Thanks in advance for any help you can provide.

    Because now still refers to the same object (the one that is created when your component is initialized). Try new Date().getTime().

  • Mouse position always zero

    Hello!
    I am developing a rather big application in Labview ver 8.2.
    I have a problem with getting the mouse position inside a picture.
    The property node mouse->mouse position always returns (-1, -1) or (0, 0). The (-1, -1) returns if the mouse is positioned over a scrollbar.
    My problem is that the (0, 0) is returned for every position inside the picture.
    Now i  wonder if anybody has any suggestions how to get the mouse position to be returned correctly.
    Best regards
    Erik Johansson

    Are you saying that you cannot reproduce the problem if you reduce it to a very small program (e.g. a loop containing only an image, appropriate property node with indicator and a small wait statement)?
    Where did your code come from? Was it converted from an earlier version or coded from scratch in 8.20? Have you tried deleting the current image indicator and creating a new one?
    LabVIEW Champion . Do more with less code and in less time .

  • SPRM Audio value always zero?

    Hi there,
    I've been working on a 5-language DVD an trying to manage the audio streams in scripts by using the SPRM audio values (SPRM 1
    Even when I been using different audio languages defaults with in the simulator, the SPRM audio value will be still displayed as zero.
    Is this a bug in the simulation or does the default audio stream that could be choosen there, take no effect to the simulator?
    Thanks for your comments and help in advance!
    Regards from Germany!

    Hi there all,
    sorry - after more tryouts I've found that there is not the language value in SPRM1 displayed, it is the audio track value!
    In this case it would be better for me to use SPRM0 values in the scripts to choose the right language track.

  • HD7950 temp sensor always zero + auto fan always 100%

    After installing new card and latest CCC software and drivers as soon as windows starts, the card fan goes to 100% even at idle.  In Performance section of CCC GPU temp reads 0c at all times even under load.
    Tried uninstall CCC, remove card, re-install card and then CCC, no dice... same problem.  I can manually adjust the fan speed in CCC but it's a PITA and shouldn't be necessary.
    Do I have a faulty temp sensor perhaps?
    Thanks....

    Quote from: flobelix on 26-November-12, 13:46:47
    Obviously either driver isn't correctly installed or it's indeed a sensor misreading caused by a defect.
    Remove current driver in safe mode using>>Driver Fusion<<. Reboot and install latest MSI driver:
    Thanks for the suggestion.  Gave it a whirl but still the same deal.  Temp 0c - Power 0% - Activity 0% - Fan 100% from the moment Win7 starts no matter what the card's doing.
    Only thing I didn't follow to a T from syour suggestion is that the free version of Driver Fusion said it required upgrading to Pro to remove all driver items even in Safe Mode.

  • Zero Amount in Gross Amount To Draw

    Dear Experts,
    I have a problem in AR Invoice screen.
    My SAP Version SAP Business One 9.0 (9.02.003) PL: 11  (32-bit)
    My scenario are:
    1. Create AR Invoice attached with AR DP
    2. In Down Payments to Draw, column Gross Amount to Draw always zero even though edited, it always back to zero again after
    Need enlighten about this.
    Thanks for your help.
    Regards,
    Deasy

Maybe you are looking for

  • Bad sound when recording presentation in keynote with animation

    When recording audio for a presentation, in a slide with some animated objects the recorded voice explaining the slide sounds crasping or double with lot of noise while the animation is taken place, after the animation the recording it's ok again.

  • Quicktime VR in Keynote 09

    Is there a way to use a Quicktime VR movie in Keynote 09?

  • OWB Mapping and Sqlloader error.

    Hi All, OWB Config Details is as follows: Oracle 9i Warehouse Builder Client: 9.2.0.2.8 Oracle 9i Warehouse Builder Repository: 9.2.0.2.0 I developed a mapping which involves a source text file delimited by comma with following structure. Deptno,Dnam

  • Apply License for Adobe Interactive Forms

    Hello Experts,                         I Have installed and configured Adobe Interactive Forms using temperory license                         Can anyone tell me under which catagory do I need to apply for Permanent License                         In

  • Which difference parallel database and RAC database

    Hi Experts, I saw some document about parallel database and RAC database. My boss confused these two product. which difference between parallel database and RAC database? does parallel database is a "old RAC"? Thanks Jim