Amount of key presses a user makes over time - BPM

Hi,
Im working on a small program that needs to get the amount of keypresses a user makes over time.
Basically its for calcuating the BPM a user is inputting. So a uers taps a beat for 5 seconds and the amount of tap is saved and multiplied by 12 to get the Users BPM.
So far i have this:
package Version1;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.*;
public class muTap extends JFrame implements KeyListener, ActionListener {
    JTextArea display;
     * main - the main method
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                theGUI();
     * muTap constructor
    public muTap(String name) {
        super(name);
     * theGUI - creates the gui for muTap
    public static void theGUI() {
        muTap frame = new muTap("muTap");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Set up the content pane.
        frame.addComponents();
        //Display the window.
        frame.pack();
        frame.setVisible(true);
     * adComponents - adds gui components to muTap
    public void addComponents() {
        JButton button = new JButton("Start");
        button.addActionListener(this);
        display = new JTextArea();
        display.setEditable(false);
        display.addKeyListener(this);
        JScrollPane scrollPane = new JScrollPane(display);
        scrollPane.setPreferredSize(new Dimension(375, 125));
        getContentPane().add(scrollPane, BorderLayout.PAGE_START);
        getContentPane().add(button, BorderLayout.PAGE_END);
    public void keyTyped(KeyEvent e) {
        //Do Nothing
    /** Handle the key pressed event from the text field. */
    public void keyPressed(KeyEvent e) {
        //TODO call the getBPMfromKboard() method
        taps++;
        System.out.println("Tap: " + taps);
    /** Handle the key released event from the text field. */
    public void keyReleased(KeyEvent e) {
        //Do Nothing
    /** Handle the button click. */
    public void actionPerformed(ActionEvent e) {
        //Do Nothing
        //initialCountdown(3, "Start Tapping Fool");
        countDown(3);
     * countDown - a simple countdown timer for use when getting users input.
     * @param time amount of time to count down from
     * @return      true when timer ends.
    public static int taps;
    public void countDown(final int time) {
        taps = 0;
        final Timer timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask()
            int i = time;
            public void run()  {
                i--;
                String s = Integer.parseInt(i); // error because of this i.
                display.setText(s);
                if (i < 0) {
                    timer.cancel();
                    if(time == 3)
                        display.setText("Start Tapping");
                        countDown(5);
                    else if(time == 5)
                        display.setText("Number of taps: " + taps);
                        //System.out.print("Number of taps" +taps);
        }, 0, 1000);
}But i get errors when i try running it:
"Exception in thread "Timer-1" java.lang.RuntimeException: Uncompilable source code"
It doesnt seem to like me parsing int to string here:
String s = Integer.parseInt(i); Any ideas? or if youve got suggestions on another way to do it it'd be much appreiated.
Thanks!

Korvanica wrote:
It doesnt seem to like me parsing int to string here:
String s = Integer.parseInt(i);
Yikes, you've got that bit of code backward, there partner.
You use Integer.parseInt to parse a String into an int, not the other way around.
If you want to change an int to a String, do
String s = String.valueOf(i)or you can use the various formatters out there.

Similar Messages

  • HT1338 how do i get voice over say the last key pressed.

    A friend is blind.    He can hear e-mail but it would begood if he could hear the keyboard keys pressed.    Will voice over say the last key pressed.

    Hi David_MadjBright,
    Sorry for the delay in getting back to you. If you haven’t already got this sorted I’ll be happy to help. Drop me an email with the details. You’ll get the ‘contact us’ link in my profile.
    Cheers
    David
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry but we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • TS1277 HI. I have followed all the appropriate steps above and when I try to enter my 'Password' when asked, my keyboard doesn't work. No key press can be activated at all when trying to enter my password in 'Terminal. And I am in the 'Administrator' user

    HI.
    I am having trouble authorising my Mac Air to my Itunes account. I found a discussion explaining how to go go into 'Terminal', then adding a command. I have followed all those appropriate steps and when I try to enter my 'Password' when asked, my keyboard doesn't work. No key press can be activated at all when trying to enter my password in 'Terminal. And I am in the 'Administrator' user. Can anybody offer any suggestions?? ta

    Does the command that you're trying to enter in Terminal begin with the word 'sudo'?
    If so, your keyboard is working fine. When you type your password after a sudo command, nothing is echoed to the screen for security reasons (not even the * that are normally registered in other user interfaces). However, the program is registering what you type.
    Just type your password and press 'return' and the command will be executed (so long as you type it correctly; if you don't, you'll get an error message).

  • How to handle form close event or escape key press event for user defined f

    Experts,
    Please let me know how to handle form close event or escape key press event for user defined form...
    Thanks & Regards,
    Pravin.

    Hi
    You can catch the form close event like this
    If ((pVal.FormType = 139 And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_CLOSE)) And (pVal.Before_Action = True)) Then
          Try
                   SBO_Application.SetStatusBarMessage(pVal.EventType.ToString())
          Catch ex As Exception
                    SBO_Application.SetStatusBarMessage(ex.Message)
            End Try
          End If
    Hope this helps
    Regards
    Arun

  • Make Tab Key Press Event

    Hi You all,
    I'm trying to make an automatic Tab Key Press after fill some data to oEditText  , plz guide me how can i do that ?
    I will appreciate your help.
    Peter.
    Edited by: PeterHoang on Oct 12, 2011 12:22 PM

    Hi
    You can use sendkeys method for this
    SBO_APPLN.SendKeys("{TAB}")
    Regards
    Arun

  • In PS5 can I make a slide show that needs a key pressing to go to next slide

    Hi I have been asked to make a DVD with a slide show on , made from a group of jpegs, that only shows a slide at a time and need a key pressing to move to the next image?. The way we used to do PowerPoint  presentations. The only way I can think is use Explorer, make the first image full screen and scroll through using the cursor keys!!! Chris

    99jon Thanks for quick and useful idea. Unfortunately I should have added in the question that the DVD was to be given to a friend who doesn't have Adobe software. Its like giving them a video DVD that they  can just load and run. I  am perhaps using a sledgehammer to crack a nut; its just that I started from this point, as PE/PS has a reliable DVD burner! Chris

  • Why hasn't Adobe navigation and user interface design improved as much as it could have over time?

    I haven't tried CS6. I'm sure it's great based on what i've seen alone. But as a user of adobe products for a number of years, i have to noticed there are still a lot of stagnant,awkward, stiff, irriating, slowing down elements found in the navigation and user interface on cs3-cs5, that i'm sure could have been eliminated or improved on at least from 2005 or 2007 onwards. I find some of these things inexcusable and unprogressive from bad traits that defined 1980's and 1990's general computer navigation and so on.
    CS5.5 has lessned this a bid bit and is more fluid in bits and pieces but for those using cs3-cs5 and in general, i find some things just horrid. As a graphic designer no one is supposed to admit the flaws or irrations of these programs. We must hail them as god, never critisize, and always adjust to new things which i think is a bit fascististic and silly
    The way the tools, options are laid out can be improved to be quicker, and easier to find and use. Using your voice as a commanding system would be helpful as well.
    A lot of cmds are too complex to remember, they can be simplier or resemble the name of the tool or option. Its makes a chore to follow this system and competition for the smart *** who memormized all the cmds.
    The way in which you loose floating side boxes, and the amount of tools or names hidden in the bars sometimes seem random and its always a constant search to find them incase you forget where they are.
    The inability to open cs4 or 5 files in cs3 is just beyond extremly annoying. Whey shouldn't you be able to open cs1 or 2 files or photoshop 9 files  as well? Every five years work expires as well?
    The layering system gets tricky and seems that a lot of things don't work when you normally move things. Its about going back, remembering and clicking on this or that, looking it up to make everything work. Sometimes which leaves you in a rut and wastes a good amount of time. You will always find this even after you've been using it for years.
    The use of the fill paint/airbrushing, clone tool, lasso tool, pen tool, history being two steps back can be vastly improved to be much better to use
    Masking and tools that have more complex features should find a way be automatically done or sampled. They can also have less complex steps and tha ability to be  previewed,  automatic or simpler  ( in case you can't remember how to do something or aren't getting it)
    A lot of the special effects, and blending modes are useless, outdated, super-ugly and don't resemble  true darkroom effects ( such as polarization, and bas-relief for example)  which they could much more vividly done. There also could be more options that are closer to repro cameras/CTP software for halftoning and more complex digital effects.
    Having to press or get used to pressing muliple keys or clicks for the most basic things simultaneously can be reduced to be easier
    Adjusting text, new documents, photos should have a smoother, quicker navigational experince where things a lot of room to be , clicked back, re-done, saved in the wrong place etc..
    Indesign could use more shapes, include more features that illustrator has, and possibly even photoshop to save time.
    There should be a way to remind you of features, complex things you've forgotten, other than history and daily usage/practice of the programs
    The help should resemble more of "visual -learners" guide books with voice features.
    There are a lot more
    Regarding other things:
    I think the price encorages more piracy and allows people to not have a concept of what is means to owning software.
    The loss of a manual or lessening of them for certain programs is a loss because it's always useful to  physical info you can flip through while looking at your program.
    I think adobe should make entirely better products for professionals or people in the industry rather than spoonfeeding the same software to all.
    They should also make less expensive add-ons like before for graphic software.
    What do you adobe could have improved over time and if so what do you think they could have improved on?

    You have this wishform to suggest improvements to Adobe products:
    https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    and the Creative Suites forums are here:
    http://forums.adobe.com/community/creativesuites
    This specific forum is only for discussions on the forums themselves, so you are not very likely to get any change by posting your comments here.

  • Hi all.When pressed play and make some changes in loop (eg fade in fade out) are very slow to implement, and also the loops from the library are very slow to play, corrects the somewhat self so is the Logic??

    hi all.When pressed play and make some changes in loop (eg fade in fade out) are very slow to implement, and also the loops from the library are very slow to play, corrects the somewhat self so is the Logic??

    Hey there Logic Pro21,
    It sounds like you are seeing some odd performance issues with Logic Pro X. I recommend these troubleshooting steps specifically from the following article to help troubleshoot what is happening:
    Logic Pro X: Troubleshooting basics
    http://support.apple.com/kb/HT5859
    Verify that your computer meets the system requirements for Logic Pro X
    See Logic Pro X Technical Specifications.
    Test using the computer's built-in audio hardware
    If you use external audio hardware, try setting Logic Pro X to use the built-in audio hardware on your computer. Choose Logic Pro X > Preferences > Audio from the main menu and click the Devices tab. Choose the built in audio hardware from the Input Device and Output Device pop-up menus. If the issue is resolved using built-in audio, refer to the manufacturer of your audio interface.
    Start Logic with a different project template
    Sometimes project files can become damaged, causing unexpected behavior in Logic. If you use a template, damage to the template can cause unexpected results with any project subsequently created from it. To create a completely fresh project choose File > New from Template and select Empty Project in the template selector window. Test to see if the issue is resolved in the new project.
    Sometimes, issues with the data in a project can be repaired. Open an affected project and open the Project Information window with the Project Information key command. Click Reorganize Memory to attempt to repair the project. When you reorganize memory, the current project is checked for any signs of damage, structural problems, and unused blocks. If any unused blocks are found, you will be able to remove these, and repair the project. Project memory is also reorganized automatically after saving or opening a project.
    Delete the user preferences
    You can resolve many issues by restoring Logic Pro X back to its original settings. This will not impact your media files. To reset your Logic Pro X user preference settings to their original state, do the following:
    In the Finder, choose Go to Folder from the Go menu.
    Type ~/Library/Preferences in the "Go to the folder" field.
    Press the Go button.
    Remove the com.apple.logic10.plist file from the Preferences folder. Note that if you have programmed any custom key commands, this will reset them to the defaults. You may wish to export your custom key command as a preset before performing this step. See the Logic Pro X User Manual for details on how to do this. If you are having trouble with a control surface in Logic Pro X, then you may also wish to delete the com.apple.logic.pro.cs file from the preferences folder.
    If you have upgraded from an earlier version of Logic Pro, you should also remove~/Library/Preferences/Logic/com.apple.logic.pro.
    Restart the computer.
    Isolate an issue by using another user account
    For more information see Isolating an issue by using another user account.
    Reinstall Logic Pro X
    Another approach you might consider is reinstalling Logic Pro X. To do this effectively, you need to remove the application, then reinstall Logic Pro X. You don't have to remove everything that was installed with Logic Pro X. Follow the steps below to completely reinstall a fresh copy of Logic Pro X.
    In the Finder, choose Applications from the Go menu.
    Locate the Logic Pro X application and drag it to the trash.
    Open the Mac App Store
    Click the Purchases button in the Mac App Store toolbar.
    Sign in to the Mac App Store using the Apple ID you first used to purchase Logic Pro X.
    Look for Logic Pro X in the list of purchased applications in the App Store. If you don't see Logic Pro X in the list, make sure it's not hidden. See Mac App Store: Hiding and unhiding purchases for more information.
    Click Install to download and install Logic Pro X.
    Thank you for using Apple Support Communities.
    Cheers,
    Sterling

  • Trap Key pressed in Forms 10g.

    Hi All,
    Have anyone trapped the keys which are pressed in Forms 10g. We have a requirement in which in a LOV Form when TAB key is pressed it should navigate to the next field and when ENTER key is pressed it should select the value from that field and get back to the field from where it was invoked.
    We had tried http://forms.pjc.bean.over-blog.com/article-15980196.html from Francois Degrelle which traps he key pressed. But that is throwing us some error in JInitiator console.
    Expecting a favorable reply from the forum users on this to .
    Thanks in advance

    Monsieur Degrell,
    is it possible to listen just to one item in the form?
    I have triedSet_Custom_Property( 'b_hilfe.bean', 1, 'INIT', 'b_help.search');in when-new-form-instance, where 'b_help.search' is the item i want to listen to,
    but the bean still listen on every item in the form.
    kind regards

  • KeyListener - how to handle series of key pressed

    Hi,
    Is there a way to handle a series of key pressed in the keyPressed(KeyEvent e) method. for instance, I want to popup a dialogbox when the user pressed: F9, 31, F9 ?
    thanks,
    chau

    Is there a way to handle a series of key pressed in
    the keyPressed(KeyEvent e) method. for instance, I
    want to popup a dialogbox when the user pressed: F9,
    31, F9 ?Look at the following.
    import java.awt.event.*;
    import javax.swing.*;
    /* http://forum.java.sun.com/thread.jspa?messageID=2900727 */
    /* http://forums.devshed.com/t218618/s.html */
    class KeyListenerDemo {
        public static void main(String[] args) {
            new KeyListenerDemo().go();
        void go() {
            JTextField field = new JTextField("Press a key, and watch the console.");
            field.setEditable(false);
            field.addKeyListener(new MyKeyListener());
            JFrame frame = new JFrame("KeyListener Demo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(field);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
    class MyKeyListener extends KeyAdapter {
        public void keyTyped(KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ESCAPE) System.exit(0);
            System.out.println("Typed: " + e.getKeyChar());
    }It shouldn't take too much imagination to figure out how to make the listener listen for that combination....

  • IPhoto opens but then the spinning rainbow wheel appears and I can't do anything. I have opend iPhoto with the Option key pressed and rebuilt the library and it still happens.  I want to at least access my photos and copy them to an external drive.

    iPhoto opens but then the spinning rainbow wheel appears and I can't do anything. I have opend iPhoto with the Option key pressed and rebuilt the library and it still happens.  I want to at least access my photos and copy them to an external drive. Anyone have ideas on how to get to them?

    Make a temporary, backup copy (if you don't already have a backup copy) of the library and try the following:
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
         User/Home()/Library/ Preferences folder.
    2 - delete iPhoto's cache file, Cache.db, that is located in your
         User/Home()/Library/Caches/com.apple.iPhoto folder. 
    Click to view full size
    3 - launch iPhoto and try again.
    NOTE: If you're moved your library from its default location in your Home/Pictures folder you will have to point iPhoto to its new location when you next open iPhoto by holding down the Option key when launching iPhoto.  You'll also have to reset the iPhoto's various preferences.
    OT

  • No long key press on bluetooth keyboard?

    I'm wondering if this is a limitation of the actual keyboard itself, iOS or even the app I'm using.  Where if you press a key on the keyboard and hold it, the iPad sends that key over and over until release.  Unlike the normal behavior of the key action 'OnDown' remaining active it simply resends the key.
    I am using the ZaggMate and Splashtop to remote into my computer a play a game.  For this game, in order to move, you need to use the arrow keys.  Since holding the key fires multiple 'OnDown' and 'OnUp' events, the movement is not fluid, more like stop, go/stop, go.
    Is there a way to work around this/where is this key press event actually getting mixed up?

    We had a couple 911 calls our first couple days with our uc540. What came up with was that our old phone system buttons had a different feel. With these cisco phones, if you press the button all the way down in a quick press, the nunbers never double for us. You can hold down forever and never get a duplicate. But if you press slowly or don't press the button all the way, I can get double numbers when pressing. I think that there's a point in the actuation that the button can float between on and off and that can give you double numbers (I think in the gaming community that this is called "spamming" the button). Our old system took less pressure to press the button all the way down and as soon as we told everyone to press harder we haven't had a accidental 911.
    If you push a button half way down and shake it left to right you can see a good example of how to spam the button. Yeah, that isn't how a person dials, but the first few days we got double-numbers just with people making calls. We have a few spa and a few 7900 series and we had issues on both but more on the spa phones.
    One specific person had the most trouble and this person doesn't have the most stable hands... She wasn't calling 911, but she just couldn't dial the right number because they'd get an unintentional double digit in the middle of their dialing. She really has to press every number deliberately to make calls--I wish I had a better solution for her because it makes here feel dumb.

  • ActiveX is stealing my key presses?

    Hi all,
    I have a fairly simple front panel with a handful of LabVIEW controls and an ActiveX container. In the ActiveX container is the Adobe Reader plugin.
    My vi works, but exhibits an odd behaviour that I presume is focus related. Once the ActiveX control is programmatically told to open and display a pdf file, it seems to steal the focus - permanently. If I select my LV string control, I can select any text in it, but key presses are all still sent to the Adobe Reader ActiveX control. If I click a few check boxes, then the string control again, it still doesn't accept my keyboard presses. The only way I've found to stop all this is to press tab, as this causes LabVIEW to move the focus away to the next control in the tab sequence. After that, all is ok until the next pdf file is read into the ActiveX control, and then I'm back at square one.
    Now I don't want to be telling my customers, "that's alright mate, just make sure you press the tab key after every pdf you generate and you'll be just fine."
    I've tried programmatically moving the focus away from the ActiveX control, and setting "SkipTabbing" to true, but this doesn't work.
    Anyone know how I can prevent this darned ActiveX control from permanently stealing my focus?
    Thoric (CLA, CLED, CTD and LabVIEW Champion)
    Solved!
    Go to Solution.

    nathand wrote:
    Unfortunately I don't have a good solution, but I can sympathize - I've had the same problem.
    Hi nathand, thanks for the sympathy 
    I've tried a few things, including navigating away from and straight back to the tab panel which houses the control to attempt to change the control focus. I've even tried simulating the keyboard TAB key press, which actually works - but only once for some annoyingly unfathomable reason! A second call to the ActiveX AdobeReader control makes it the focus again, but this time permanently. I've even tried putting the ActiveX control into a subvi that's hosted within a subpanel - no difference.
    Ultimately, like yourself, I've had to settle for a separate window, which I've called a Preview Window. Of course, putting my large ActiveX container in a separate subvi has left a dirty big empty space on my main vi front panel 
    I'm tempted to try to hide all borders around the preview window, and programmatically control its location such that it sits perfectly over the empty space within my main front panel. Of course, this means monitoring main panel window resizes and movements to maintain the correct relative locations, but it's do-able...
    I've got a new problem now - I thought about using Invoke to Get the Front Panel Image, then place this into a picture control. However, it seems the AdobeReaderActiveX control evades the LabVIEW Front Panel Image method, revealing nothing but the blank front panel colour behind the container. I can't seem to find a way around this either!
    Dam dam dam dam dam dam dam dam dam dam dam dam!!!
    Thoric (CLA, CLED, CTD and LabVIEW Champion)

  • How to trap key press in Forms6i?

    Hi,
    We have an Client/Server Application developed in Forms6i. The same application also runs over the web with 9i Application Server.
    For some particular application requirement, we need to execute a routine
    after every key pressed by the user in the text control. Hence we need trap every key thats pressed by the user.
    Any help would be greatly appreciated.
    Raj

    You can do this on the Web Deployed one using a PJC - See the KeyFiler example in the Forms Demos (it's in the 9i demos and available for 6i as well)
    For client server you'd have to look at an OCX for this.

  • How can we trape the Keys Pressed on the Keyboard and do action depending on the keys

    I want to know how we can capture the keys pressed on the keyboard by the user and do necessary action depending on the key pressed by the user....
    For example.... If user press Alt+q the form should go in the Enter Query Mode.
    Can anyone tell me how i can do this in Form 6i....
    Please Help me out from this problem...
    Thanks in Advance
    Shan

    Can somebody point me to what I need to use to
    intercept all the 'keys' for an application.
    At the moment I have set Focus to parts of the
    application when the Mouse is over it, and then get
    the Keys with a KeyListener.
    Is there a way to get the keys, as long as the Java
    app is active.
    - Its an image display program, and I want to use keys
    for - next image , zooom etc etc.
    If soemone could just point me to the right part of
    the API to look in?java.awt.Toolkit.addAWTEventListener()
    then use the mask defined in AWTEvent.KEY_EVENT_MASK to listen to all the events.
    Steve

Maybe you are looking for

  • ABAP Program to update DSO data

    Hi, I want to write a program which will modify existing data in the DSO. But don't know how to approach. I know I can't directly update data table of DSO. Please help.

  • File order in FAT HD

    Hey guys, I'm having a problem with an external HD. I've copied several video files (mostly mkv and avi, sorted into folders) to this external HD (that is FAT formatted). And the thing is, I'm using this HD on a Philips TV, that shows the order of th

  • Vendor consignment return and vailability check

    Dear friends. We created a vendor consignment PO(K in item category and tick return box) and realized PO was committed from unrestricted stock instead of consignment stock,which cause no availability check in sales order due to insufficient available

  • "Database Audit Specification" not available.

    Hi all,  Been asked by one of the developers to audit delete & insert for one night only so I thought to investigate built in auditing via "new Database Audit Specification".  I am in the sysadmin role but no  option to add a database audit, the serv

  • [XSU] OracleXMLSave

    Hi! I have a problem with loading XML file with OracleXMLSave. I would to load an XML file 2 levels deep in an object-relational table in Oracle 9.2.0.1 the problem is generating the right schema DB for sustain the 2 level deep XML file. my file is l