Using a textfield for input from keyboard to cause events

Ok I know very little about java and even less about handling events... I am reciving conflicting information from different sources like webpages and the JDK docs but I so far have this code which compiles but doesn't work. I want it to draw an oval if the user inputs an a.
public boolean Action(Graphics g, Event evt, Object arg){
          boolean a = true;
          if (evt.target instanceof TextField){
               if (evt.target.equals(movement)) {
                    direction = direction();
                    System.out.println(direction);
                    clear();
                    if(direction == "a"){
                         g.setColor(Color.decode(randomHex.Colour()));
                         g.fillOval(10,10,10,10);     
                    }//end if direction
               }//end if target
               else {
                    a = false;
               }//end else
          }//end event target textarea
          return(a);
     }//end action
This of course is only my action method. I look forward to posts that'll help me out. Thx a lot guys.

Assuming that "direction" is a String variable, don't do this:if (direction == "a")Instead, do this:if (direction.equals("a"))Your code tests whether the direction variable and the "a" constant refer to the same String object, which they won't. The revised code tests whether the direction variable contains the same characters as the constant "a".

Similar Messages

  • Can I use debit card for purchasing from iTunes in India?

    Can I use debit card for purchasing from iTunes in India?

    Hi
    There is a small discussion that iTunes takes debit card with a Visa/Mastercard logo.  I have no idea what the banking rules are in India.  But this may another option to try.
    https://discussions.apple.com/thread/3658843?start=0&tstart=0
    Cheers

  • How to get default input values when using promt user for input

    I use "promt user for input" to input some values. The messageboard appears with blank boxes then I will input  new values. I want to make some default values in this blank boxes so that I needn't to enter new values. Is it possible ?

    Right click on he Express Vi terminal and choose open Front panel to convert it into a standard vi. Then open it. Enter a default value for each control, then right-click on the controls and go to data operation > make current value default.
    Message Edité par chilly charly le 11-18-2007 12:52 PM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • HT4796 I started Migration Assistant and then my old computer spontaneously restarted.  I am back in Migration Assistant but my [new] iMac is still waiting for input from my old computer, and my old computer is waiting for the iMac to connect.  What do I

    I have a new iMac.  I'm using Migration Assistant to transfer files.  My old computer spontaneously shut down.  I restarted it and am trying to use Migration Asst again, but each computer is waiting on input from the other one.  What do I do?

    Let me see if I've gotten this right! You want to remove an account from BOTH machines? Do this for your new machine first, then for the other.
    Click the Apple logo on the top left of the screen, System Preferences, Users and Groups (under Systems), unlock the lock in the window if its locked (you need to know the password), select the user that you wish to remove, and click the - sign next to the + sign for Login options. A window will pop up with some options. Select Delete this user and securely, and click 'Delete user'.
    After this, do an update from the App Store.
    Thats all there is to it.
    For the other machine repeat the process except for one thing. Before you delete the user in this case YOU, you will have to give Administrator priviledges to your son bu checking the box 'Allow user to administer this computer'.
    Do NOT do anything from Finder ... if you dont know how to fix the consequences of the problems caused.
    There is no need to unauthorize your iTunes account on your new machine. Do it on the old machine though.

  • Embedd excel in browser, use excel interface for inputing values.

    Embed excel sheet in browser and give application same functionality as excel sheet gives. We can use the excel sheet for input and able to update the values in database.
    Please provides the solution as how to do it. Is there any reply...........

    you can use applet to do this work.
    Jxcell spreadsheet somponent is a excel compatible spreadsheet.
    It can be embed in java applet.support cell format,formula,pic,chart etc,
    all these can exchange with Excel.
    http://www.jxcell.net

  • Using table rows for input

    Hi,
    Is it possible to use rows of table for input? Table binded to a RFC model table parameter. The rows of table is looking readonly. 
    Best regards,
    Altug Bayram

    Hi,
    Did u check if the  attributes set to read only. ?
    What is the cardinality of the node.
    And when it is a input for the RFC , i think you have missed the createElement part...!
    P.S : It will be gain more attention when it is a seperate question.
    Regards
    Bharathwaj
    Message was edited by: Bharathwaj R

  • Using Logic sounds for input and playback in Sibeius

    Hi. I've been running Sibelius and Logic on different PC's, and just for fun, I installed Sibelius on my Mac today. I used my Master Keyboard to play in a test song.
    So now I'm wondering whether I can use Logic sounds for inputtting AND for playback. Since I also have VSL on the mac, I don't really want to install the GPO which I use on my Pc with Sibelius.
    Thanks, Kay.

    Have you think using IAC ? I.e you set it as a "Midi Out" port in Sibelius so the midi will carry the data to Logic and trigger its Instruments via the virtual midi cables ( the IAC bus ).
    Take care to select Software Instruments tracks only. If you select some track which use say Multi, Standard or Mapped Insr. ( which port is set to IAC by chance ) you will cause midi feedback and crash the Logic app.
    !http://img59.imageshack.us/img59/4967/aglogo45.gif! [www.audiogrocery.com|http://www.audiogrocery.com]

  • Stuck at password screen and doesn't take iny input from keyboard or mouse

    Laptop started and some msg appeared the automatically shut down... Again automatically started but stuck on password screen which neither take input from kayboard or mouse.. Pls help

    Ditto for about a week. Happens maybe every 24-48 hours.
    IIRC, I applied some routine MS Updates prior.
    T510, Win7 Professional, Nvidia GPU.

  • How do you store input from keyboard into a string array

    I am trying to learn java and one of the programs I am trying to write needs to be able to accept a machine hostname at the keyboard and stuff it into a string array element. I am sure I will be using something along the lines of:
    BufferedReader in = new BufferedReader(new InputStreamReader(
                             System.in));
                   String str = "";
                   System.out.print("Enter a FQDN to look up: ");
                   str = in.readLine();
    but how do I get the input stuffed into hostname[ ].
    Any hints or assistance will be appreciated.
    Michael

    Well part of. I need to be able to take a random number of hostnames (ie. mblack.mkblack.com, fred.mblack.com, joe.mblack.com, ...) and after the user presses the enter key between each entry, the inputted information is stored in an array element. for example with the three shown above the array would look like this after the user finished.
    hostname {"mblack.mblack.com","fred.mblack.com","joe.mblack.com"};
    the algorithm would be
    Prompt for hostname
    get user input and press enter
    store hostname into array element
    prompt for next hostname or enter with no input to complete entry and execute lookup.class methods.
    I have the program written and working fine if I use a static array where I put the hostnames in the list, but cannot figure out how to get the information from the keyboard to the array element.
    Thanks for the help though, the response is very much appreciated.
    Michael

  • How to get input from keyboard scanner into an array

    This is probably a very basic question but I'm very new to java..
    My task is to reverse a string of five digits which have been entered using keyboard scanner.
    E.g. - Entered number - 45896
    Output - 69854
    I used the StringBuffer(inputString).reverse() command for this, but i need a more basic method to do this.
    I thought of defining an array of 5
    int[] array = new int [5];
    and then using,
    Scanner scan = new Scanner(System.in);
    to enter the numbers. But I can't figure out how to get the five input numbers into the array.
    If I can do this I can print the array in reverse order to get my result.
    Any other simple method is also welcome.

    Hey thanks for the quick reply,
    But how can I assign the whole five digit number into the array at once without asking to enter numbers separately?
    E.g. - if entered number is 65789
    Assign digits into positions,
    anArray [0] = 6;
    anArray [1] = 5;
    anArray [2] = 7;
    anArray [3] = 8;
    anArray [4] = 9;
    I'm really sorry but I am very new to the whole subject.

  • Input from keyboard

    Hey everyone, I'm new to java and am having some problems.
    I'm trying to make a simple program that reads a numeric value
    entered from the keyboard, and then adds or subtracts it from
    another variable for the final output. Ive gotten input to work with
    chars, but I need int. Any help would be much appreciated.

    See if this helps
    // The "Input" class.
    import java.io.*;
    public class Input
        public static void main (String [] args)
            try
                System.out.print ("Enter Int: ");
                BufferedReader input = new BufferedReader (
                        new InputStreamReader (System.in));
                String userInput = input.readLine ();
                int intValue = Integer.parseInt (userInput);
                System.out.println (intValue);
            catch (NumberFormatException ex)
                System.err.println (ex.getMessage ());
            catch (IOException io)
                System.err.println (io.getMessage ());
        } // main method
    } // Input class

  • HT1295 Is it possible to use vst plugins for garageband from an external hard disk? (Without installing to the system hard disk)

    Hi,
    I got my MacBook pro 17" installed a 250GB of SSD as a system disk.
    And i got 4TB of Thunderbolt External Disk.
    The thing that i want is: to use my VST plugins for Garageband or Logic without fulling the system disk. Is it possible use them from an external disk?
    Thnx

    Garageband can't use VST plugins.
    If you're talking about AUs: you could try to put an alias into the HD/Library/Audio/Plug-Ins/Components folder instead of the actual files, and see if GB loads them.

  • Curiosity: How to use a table for input when testing a functionmodule?

    actually I am sick of writing test programs for every function I want to test using ABAP.
    So why it is (made) impossible to generate input data for a table as input parameter of a functionmodule?
    Has really nobody ever tested this stuff when the test function was implemented in SE37 or was this bug implemented on purpose to generate work?

    Andreas,
    You can input data into the internal table by:
    Test FM
    > Testing initial screen --- click on the table icon against your table parameter
    > Input your input data in the fields
    > to Input more lines in the table.. press Insert Line (icon with plus sign)
    After this press back button.
    Now, you will have your test data in the tables.
    Regards,
    Naimesh

  • Best way to make program wait for input from NI USB 9162?

    Hi, I'm somewhat new to Labview, but through all the tutorials and online help I'm still having trouble getting this to function properly.
    The USB adapter is hooked up to a network cable split into single wires reading in a voltage coming through several seperate oscillators.  
    Testing in the lab, the program included below works fine when I run the program, then quickly administer a shock to the table.  In the real world scenario though, I'm trying to make the program wait to record data until the first shock reaches the first oscillator before recording data, but I just can't seem to find an easy way to make this work.
    Attatched is an example of the program.  Any help would be greatly appreciated.  Thank you. 
    Attachments:
    Acq&Graph Voltage-Int Clk-rh-tt-1.vi ‏56 KB

      Hi,
    I think I have the answer you're looking for! Please see the attached VI.
    I moved the graph indicator inside the "true" case of the case structure. Before, your VI was sending data  to the graph from an empty timestamp constant with each iteration of the "false" case. Now the VI only sends data to the graph if a true is read.
    If you're wondering why it takes a bit of time for your graph to stop updating before it stops writing new data, it's because you're filling up a buffer of sampled data by using a queue. If you're writing to the buffer faster than you're reading from the buffer, you may encounter an "overflow" situation when the queue gets full. To avoid this, you might consider using a notifier rather than a queue. It's the exact same thing as a queue, but it gives you only the most recent value, allowing new values to overwrite old values.
    Hope this helps.
    Regards,
    Dan Richards
    Certified LabVIEW Developer
    Attachments:
    producer consumer DAQmx threshold.vi ‏57 KB

  • TextField (for Input) which supports alignment and number format - AJAX?

    Dear forum members,
    I have a tabular form containing a lot of number fileds shown as TextFileds, where Users may input large numbers.
    Is there any way to let the numbers inside the TextFileds be shown right aligned.
    And maybe using a number format, which the user isn't bound to follow (just for display)?
    Thank you
    Johann

    Hello Johann,
    In the Column Attributes set the Element Attribute (in the Tabular Form Element) to style="text-align:right" for right alignment.
    You can use the Number / Date Format (in the Column Formatting) to 999G999D99 (or whatever you like) to get a number format.
    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    http://www.bloggingaboutoracle.org/
    http://www.logica.com/
    You can award this reply to your question by marking it as either Helpful or Correct ;-)

Maybe you are looking for