How do you count the amount of times a button is clicked?

Heres my code:
public void buttonClicked(JButton buttonzilla){
if(buttonzilla == startButton){
while(i < 7){
story.append("\n" + "\n" + abc);
i++;
However, when i click the button once, it displays all elements in the array, however, im trying to get it so that each time i click the button another element is displayed, one at a time. How would i go about doing this?

Can you explain the code because it dosent make sense
to me, im a beginner.In the code you posted, there is no declaration for the variable i, so I've assumed it is declared as a class variable, and has scope within the class.
You say you want to add only the data from the element of abc[], relative to the number of times the button has been clicked i.e. 1st click adds abc[0], 2nd click adds abc[1] etc.
if(i < abc.length)  - to ensure no ArrayIndexOutOfBoundsException (really should also check i is not negative)
story.append("\n" + "\n" + abc[i++]);
instead of
story.append("\n" + "\n" + abc);
i++;

Similar Messages

  • How do you set the amount of time the screen stays lite after your last use?

    How do you set the amount of time the screen stays lite after your last use?

    Settings>General>Auto-Lock.

  • How do you count the multiple columns of a field in a table

    How do you count the multiple columns of a field in a table

    Hi,
    4396bf34-e890-4202-a6b0-4e08c9ff0e89 wrote:
    How do you count the multiple columns of a field in a table
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    "Field" isn't a standard database term.  Some people say "field" when they mean "column", but I don't think that's what you mean ("How do you count the multiple columns of a column ..").  Do you want to know how many times a column is used (as opposed to NULL), or the number of different values in a column?  You really need to show what you want.

  • How do I adjust the amount of time before time outs?

    Time outs happen too quickly. I want to extent the amount of time that elapses before it times out while loading a site.

    Hello Scootdog61,
    Thank you for using Apple Support Communities!
    The setting you are looking for is shown in this article:
    iOS: Understanding passcodes
    http://support.apple.com/kb/HT4113
    Just above Simple Passcode, the setting that says Require Passcode.
    Regards,
    Sterling

  • I have a Samsung S5, How can i increase the amount of time my phone rings?

    So as stated in the Subject, I have a Samsung S5 it works really well so far, However when someone is ringing me it only rings 3 times. Is there a way i can increase the amount of times the phone rings before it goes to answer machine?

    Hi, 
    Try this: 
    1. Dial *#61# and click Send. You will see your VM access number and the current ring delay time.
    2. Write down the phone number displayed (including +1).
    3. Dial **61*+1xxxyyyzzzz*11*30# and hit Send. +1xxxyyyzzzz is the number you wrote down previously, 30 is the delay in seconds. The delay can be set in 5 second increments, 30 is maximum.
    4. Dial *#61# to verify that the new settings are active.
    Thanks, 

  • How do you reduce the amount of mb used by other i dont know what this is?

    how do i reduce the amount of mb used by other on my itunes do i can record more videos?

    http://osxdaily.com/2013/07/24/remove-other-data-storage-iphone-ipad/

  • How do I count the number of times a word appears in a column?

    What I have is a spreadsheet logging work history. Let's say the work location is "office", "home", or "travel" and I want to have a separate cell in another table for totals, count up the number of time each appears in the data for the year. So it would look like this:
    Date
    Location
    sept 1
    office
    sept 2
    home
    sept 3
    home
    sept 4
    travel
    sept 5
    office
    sept 6
    office
    sept 7
    office
    sept 8
    travel
    sept 9
    home
    sept 10
    office
    Totals
    Days
    10
    Office
    5
    Home
    3
    Travel
    2
    I just can't figure out how to develop the formula to put in the Totals column to make it work this way. If you can help me achieve this I'd really appreciate it!

    Hi SpartanAntarctican,
    Table 1 to record your locations
    Date
    Location
    sept 1
    office
    sept 2
    home
    sept 3
    home
    sept 4
    travel
    sept 5
    office
    sept 6
    office
    sept 7
    office
    sept 8
    travel
    sept 9
    home
    sept 10
    office
    Table 2 to sum your locations
    Totals
    Days
    10
    Office
    5
    Home
    3
    Travel
    2
    In Table 2 the formula in B2
    =ROWS(Table 1::A)−1
    Minus 1 because there is a Header Row in Table 1.
    In Table 2 the formula in B3 (and Fill Down)
    =COUNTIF(Table 1::B,A3)
    You can check this by adding 5 + 3 + 2 to arrive at 10
    Or maybe delete Row 2 put the Days calculation into a Footer Row in Table 2
    =SUM(B) .
    Regards,
    Ian.

  • How do i change the amount of time for slides in a keynote presentation so they are not the same

    how do i vary the times for the slides in a keynote presentation, i have 3 videos i need to run longer and the slides I want to run the same

    Is this for an unattended presentation?
    1. If not, the option would seem to be:
    Manually advance the slides containing the videos or
    set the transition delay time to the next slide to occur after the video completes using the
    Slide > Transition Inspector > Delay (max delay is 600 seconds so if video is longer than 10 minutes, an automatic delay wouldn't work)
    2. If you plan this to be unattended your best bet is to compile it in iMovie and have a looping video with all parts timed in the video to your liking.

  • How do i count the number of times a cell has been referenced by other cells' formulae?

    Hello,
    I have a spreadsheet of recipes and ingredients that use checkboxes to let me know which recipes I can make based on the ingredients I have on-hand, using a formula like this one: =IF(AND('Spirits' :: A42,Mixers :: A18,Mixers :: A41,'Spirits' :: A25 ),Table 3 :: $A$2,Table 3 :: $A$3). If I've checked all of the boxes for ingredients that are required for any one of my recipes, the cell that the formula is in returns something like "YES"; otherwise, it returns a blank. It works well enough, but I'd like to include a cell next to each ingredient with a formula that will look through the hundreds of recipes, which all use a formula like the one above, and return a count of the number of times the ingredient's cell is referenced in those formulas. That way, I'll know which ingredients are the most commonly used in my eclectic collection of recipes. I thought something like =COUNTIF('Recipes' :: A2:A343, "=A2") would work, but it doesn't look at the cell references in the formulas, so no, it doesn't work. Any ideas? I'm using Numbers 2.3

    Hello
    There's no formula to inspect other formula in Numbers. So what you asked cannot be achived in such a way you described.
    A simple alternative method would be to build recipe-ingredient matrix as follows.
    E.g.
    Table definitions:
    Recipes
    A1    Recipe \ Ingredient
    A2    A
    A3    B
    A4    C
    A5    D
    A6    E
    A7    F
    A8    # recipes / ingredient
    B1    X1
    B2    TRUE
    B3    FALSE
    B4    TRUE
    B5    FALSE
    B6    TRUE
    B7    FALSE
    B8    =COUNTIF(B,TRUE)
    C1    X2
    C2    TRUE
    C3    TRUE
    C4    FALSE
    C5    TRUE
    C6    TRUE
    C7    TRUE
    C8    =COUNTIF(C,TRUE)
    D1    X3
    D2    FALSE
    D3    TRUE
    D4    FALSE
    D5    TRUE
    D6    FALSE
    D7    TRUE
    D8    =COUNTIF(D,TRUE)
    E1    X4
    E2    FALSE
    E3    FALSE
    E4    FALSE
    E5    FALSE
    E6    FALSE
    E7    TRUE
    E8    =COUNTIF(E,TRUE)
    F1    Y1
    F2    TRUE
    F3    FALSE
    F4    TRUE
    F5    TRUE
    F6    TRUE
    F7    FALSE
    F8    =COUNTIF(F,TRUE)
    G1    Y2
    G2    FALSE
    G3    TRUE
    G4    TRUE
    G5    FALSE
    G6    FALSE
    G7    TRUE
    G8    =COUNTIF(G,TRUE)
    H1    Y3
    H2    TRUE
    H3    TRUE
    H4    FALSE
    H5    TRUE
    H6    TRUE
    H7    FALSE
    H8    =COUNTIF(H,TRUE)
    I1    Y4
    I2    FALSE
    I3    FALSE
    I4    FALSE
    I5    FALSE
    I6    FALSE
    I7    TRUE
    I8    =COUNTIF(I,TRUE)
    J1    in-stock?
    J2    =SUMIF(B2:E2,TRUE,TRANSPOSE(X::$C$2:$C$5))+SUMIF(F2:I2,TRUE,TRANSPOSE(Y::$C$2:$C$5))=COUNTIF(B2:I2,TRUE)
    J3    =SUMIF(B3:E3,TRUE,TRANSPOSE(X::$C$2:$C$5))+SUMIF(F3:I3,TRUE,TRANSPOSE(Y::$C$2:$C$5))=COUNTIF(B3:I3,TRUE)
    J4    =SUMIF(B4:E4,TRUE,TRANSPOSE(X::$C$2:$C$5))+SUMIF(F4:I4,TRUE,TRANSPOSE(Y::$C$2:$C$5))=COUNTIF(B4:I4,TRUE)
    J5    =SUMIF(B5:E5,TRUE,TRANSPOSE(X::$C$2:$C$5))+SUMIF(F5:I5,TRUE,TRANSPOSE(Y::$C$2:$C$5))=COUNTIF(B5:I5,TRUE)
    J6    =SUMIF(B6:E6,TRUE,TRANSPOSE(X::$C$2:$C$5))+SUMIF(F6:I6,TRUE,TRANSPOSE(Y::$C$2:$C$5))=COUNTIF(B6:I6,TRUE)
    J7    =SUMIF(B7:E7,TRUE,TRANSPOSE(X::$C$2:$C$5))+SUMIF(F7:I7,TRUE,TRANSPOSE(Y::$C$2:$C$5))=COUNTIF(B7:I7,TRUE)
    J8   
    X
    A1    Ingredient
    A2    X1
    A3    X2
    A4    X3
    A5    X4
    B1    in-stock?
    B2    TRUE
    B3    TRUE
    B4    TRUE
    B5    FALSE
    C1    code
    C2    =IF(B2,1,0)
    C3    =IF(B3,1,0)
    C4    =IF(B4,1,0)
    C5    =IF(B5,1,0)
    Y
    A1    Ingredient
    A2    Y1
    A3    Y2
    A4    Y3
    A5    Y4
    B1    in-stock?
    B2    TRUE
    B3    FALSE
    B4    TRUE
    B5    FALSE
    C1    code
    C2    =IF(B2,1,0)
    C3    =IF(B3,1,0)
    C4    =IF(B4,1,0)
    C5    =IF(B5,1,0)
    In "Recipe" table, the first row is header row and the last row is footer row.
    Hope this may help,
    H

  • How do I extend the amount of time on a DVR HD/SD Program?

    I recorded the Oscars in HD on my DVR last night but they went past the programs allotted time causing me to miss the last 3 awards. How do I add time to programs...what are my options? Vickie.

    Rebalol wrote:
    Unfortunately, all the suggestions everyone gave you were if your program hasn't started. If it is already recording, your only option is to record the program right after it.
    Actually, there is another option.  Go intot the DVR menu and set a manual recording.  This is especially useful if you only want to add 15 minutes and the show following is 90 minutes.  Saves a lot of recording storage time if the programs are all HD.
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.

  • How do you change the date and time

    how do i changethe time and the date on  hp photosmart plus B210 all in one series

    In most printers you go to the setup icon on the display, and then to either tools or preferences. In one of those menus there will be an option to adjust the date and time.
    Jon-W
    I work on behalf of HP
    Please click “Accept as Solution ” on the post that solves your issue to help others find the solution.
    Click the KUDOS STAR on the left to say “Thanks” for helping!

  • Find one character in a string and count the amount of times its found

    Hey SQL Forum experts.
    I have a string that is about 3000 characters long.
    I'm trying to search my string for the value '{'.
    Then I want to count how many times this value is found.
    How do I form the Oracle SQL to do this?

    Hi Colin,
    Try the following:
    SQL> var s varchar2(100)
    SQL>
    SQL> exec :s := 'Colin {{ Mackenzie {{{'
    PL/SQL procedure successfully completed.
    SQL> select length(:s) - length(replace(:s, '{')) Matches from dual;
       MATCHES
             5
    SQL> exec :s := 'I have a string that is about 3000 characters long'
    PL/SQL procedure successfully completed.
    SQL> select length(:s) - length(replace(:s, '{')) Matches from dual;
       MATCHES
             0Regards.

  • How do you alter the event start time

    The event start time always defaults to 5:00 pm. How do I change this.

    Thanks for replying. Yes my event time is responding as you pointed out, however I' putting on a number of events at about 4:00 pm that all start about 8:30 am so it would be very useful if the default time could be set for a specific time. Thunderbird is version 31.5.0, I only started using this programme a few days ago and downloaded the Lightening Calendar at that time. Could not find how to find the version of Lightening perhaps you could help there as well. Regards

  • How do you know the date and time synchronization in the windows version?

    Where can I see the date and time synchronization?

    There's a toolbar button sitting in the Customize Palette. Move that button to a toolbar or into the Open Menu box; when you hover the cursor over that button a tooltip will appear with the day-of-week and the time of the last Sync event.

  • How do you limit the amount of digits in a text field?

    If a user was to input 9 digits into a text field. How do you make it so that an error message would appear if the user inputs more than 9 digits

    That code will set the TextFields length to 9 standard charecters (might not be 9 though) To limit the number of charecters and throw an error message I would use a listener on the textField. Perhaps a keyListener that keeps track of the number of charecters. ( swing has document listeners which are really nice )

Maybe you are looking for