9x9 array of buttons and not a single button worked

im trying to build a 9 x 9 block composed of buttons. I used array of buttons.
here's my code with my explanation and poor logic thinking details.
public class ButtonArrayDemo extends JFrame implements ActionListener
private JButton[] sButton;
private int[] x;//manipulation purposes only
public ButtonArrayDemo()
     JPanel buttonPanel = new JPanel();
     buttonPanel.setLayout( new GridLayout(9, 9) );
     sButton = new JButton[81];
     x = new int[81];
// creates the buttons,action listeners, syntax is correct but
// i doubt the logic
     for (int i = 0; i < sButton.length ; i++)
          JButton button = new JButton();
          button.setText(" ");
          button.addActionListener(this);
          sButton[i] = button;
          buttonPanel.add(sButton);
          x[i] = 0;
     getContentPane().add(buttonPanel,BorderLayout.SOUTH);
     setResizable(false);
// what i want for this is that, when a button is clicked, it displays the
//number 1 then increments by 1 if clicked again. Like,when i click a
//blank button, it displays the number "1", if i clicked it again, it displays
//the number 2. This goes on until number 9. When the button is clicked
//on the 10th time, it leaves the button's text blank. Syntax is fine but
//i doubt the logic.
public void actionPerformed(ActionEvent e)
     int y;
     for(y = 0; y < sButton.length; y++)
          if(e.getActionCommand().equals(sButton[y]))
               sButton[y].setText(Integer.toString(++x[y]));
               if(x[y] == 10)
               sButton[y].setText(" ");
               x[y] = 0;
Now, i created the main and compiled the program. The frames appeared complete with 81 buttons. But, when I click on any button,
it does nothing. The button's text which is supposedly to change is not displaying anything. this is a vital thinking process for me and any help from someone would be very much appreciated.
thanks for reading and i hope someone will respond to my problem.
lots of thanks.

I believe the problem is that you are using the actionCommand but you did not set the actioncommand for the buttons. I suggest you either set the action command for each button to a unique item or use getSource instead.
Also, you might want to break out of your for loop once you find the correct button.
Also, if the future use the code formatting tags and this probably should have been in the Swing forum.

Similar Messages

  • Some albums I put on my Mac to later sync with a Touch appears as seperate tracks and not a single album.  How do I get them back together again other than a playlist.  I do not want the tracks showing up as albums on the Touch?

    Some albums I put on my Mac to later sync with a Touch appears as seperate tracks and not a single album.  How do I get them back together again other than a playlist.  I do not want the tracks showing up as albums on the Touch?

    Are your tracks pat of a collection? Different artists, but still one album? Then mark them a s acollection or set the album artist. See this guide on how to group separate tracks into albums:
    iTunes: Grouping Tracks Into Albums

  • When I download a cd it loads as separate songs and not a single album

    When I download one particular  CD to I Tunes on my Mac Book Pro it loads as separate songs and not a single a single album.

    You may need to add the artwork manually. Google can help you find good quality album covers.
    Are these compilation albums with multiple artists? If so and you have entered individual artists in the Artist field the albums will show up in the iTunes Browser as you describe. To fix it set the Album Artist to "Various Artists" (without the quotes) and this album should display properly; or, highlight the full album, do a Get Info and click the Options tab and make "part of a compilation" YES.

  • I have a new Mac Mini and all my software is up to date. My video keeps acting up, flashing and not allowing me to work. This was happening with my old machine as well. Is this a problem with my monitor or do I have a bug somewhere in  my system?

    I have a new Mini and updated software. My monitor will keep flashing back and forth, shrinking the display and not allowing me to work. Sometimes clicking the mouse helps, sometimes clicking into the screen but it freezes up and won't allow me to work. Is this a monitor problem or is there some bug in my system.

    Try just holding down on the power and home buttons to restart it. Thomas R. doesnt know what he was talking about. The tool is not made for jailbraeking and is not related to jailbreaking. If you want to get the link again, let me know, as I reapir iPhones, have been using it for years, nad it does NOT void your warranty. It simply reboots your device.
    My apologies for all of the new people on this site who are novices to anything beyond iTunes or the device itself. Hopefuly your problem is solved.

  • New software update has cleared my contacts and notes app no longer working

    Help!  I'm traveling and today when I turned on my phone getting off the plane, the s/w updated and all of my contacts are gone.  i use the HTC People app, not google contacts.   Also the Notes application no longer works, and comes up with an error to force close.    Any ideas on reversing the s/w upgrade or getting my contacts back?  Thank you.

    If you were using Verizon's backup assitant you should be able to hit Menu | Settings | Accounts & Sync | add account and select backup assitant and it should prompt you for your pin number and restore your contacts. If you were not your only option for restore would be if you had backup software installed, or if you sync'ed using HTC Sync to outlook or some other program...I wish you the best of luck.

  • Ive tried to update my iphone by using wifi but the wifi connection got interupted and not my iphone wont work

    Ive tried to update my iphone by using wifi but the wifi connection got interupted and not my iphone wont work

    Connect your iPhone to a computer and use iTunes to perform the update.
    ~Lyssa

  • Inspection lot for production order lot and not for single pieces

    Dear all,
    I have a production order , for example, for 12 pieces / serial number . Material is produced in lot , in this case 3 lot of 4 pieces.
    Pieces in a lot are linked toghether in a grap.
    Production order create an inspection lot where I can store quality data for every pieces / serial number.
    I need to store quality data at lot level ( for example the grap weight );
    Is it possible ?
    Regards

    Can you not create Char/MIC like weight & attach the task list to the inspection lot?

  • Hi all, I'm new here and not sure how things work.

    I just wanted to know how do I install adope 10.1 on my iPad 4 for the use of ufilling. Your assistance will be appreciated. Thanks.

    fanamotaung,
    As of today (August 10, 2014), the latest version of Adobe Reader is 11.3.2, which runs only on iOS 7.  10.1.0 is the very first version of Adobe Reader for iOS released back in October 2011.  It is rather obsolete and does not provide the support for form filling.
    If the operating system of your iPad 4 is iOS 5 or 6, you will get a dialog like this when you try to install Adobe Reader from the App Store.
    You can tap the Download button to install an older version of Adobe Reader for iOS.
    However, we'd highly recommend updating your operating system to the latest iOS 7.1.2 and installing the latest version of Adobe Reader (unless you have a reason why you do not want to update iOS).
    Once you install Adobe Reader for iOS, you can launch it and tap Help in the Reader home screen to see the in-app Handbook (Help documentation),  It has a lot of useful information to get you started on Adobe Reader for iOS.
    Please let us know if you have additional questions.

  • Very hard to download adobe flash onto my Mac..two times and not sure whether it worked

    cant understand why it is now so difficult to download the adobe flash onto my Mac. It took two times and still not sure if it took.

    Can you see the Flash animation at http://helpx.adobe.com/flash-player/kb/find-version-flash-player.html ?
    [topic moved to Flash Player forum]

  • Cable light not coming on and not charging.  Outlet working

    I plugged in my charging cable as usual and light did not come on.  Outlet working.  Tried several times to get to "sit" correctly.  Yesterday I had problem with wi-fi.  I noticed there was a red light on one setting, something that began with "fire..."  I got wi-fi to work again.  Don't know if there is any connection to problem right now, but I am down to about 7% power!
    Kathy

    First make sure both male and female MagSafe connectors are perfectly clean and the gold pins on the cable end are all sticking out (see here, especially #7, click on the triangle to open: http://support.apple.com/kb/TS1713 ). Then try to do an SMC reset: http://support.apple.com/kb/HT3964
    If that doesn't solve the issue, the power brick may be bad and require replacement. Do you have access to another power brick to test and see that the charging circuits are ok on your Mac?

  • Not a single format will import

    I have a flip video which records in AVI. Older iMovie had no problem importing this. I spent several hours at the Apple store Genius bar a month or so ago and we developed a workaround using Toast Titanium to convert my AVI files to Quicktime so iMove '09 will work. However, tonight NOTHING works. I have converted my video into every kind of file known to man and not a single one will import into iMovie. I've tried quicktime, quicktime custom, H.264, Mpeg-4, DV...I've tried putting them into iPhoto first. I've tried putting them into iTunes first. NOTHING is working. What the heck do I have to do to get my stupid movies into iMovie?!?

    If you are using the old *Standard Definition Flip Video Camera* in conjunction with *iMovie '09* all you need to do is install the 3ivxVideoCodec.component
    http://support.apple.com/kb/HT1989

  • "open with" opens CS6 and not CC

    I have CS6 and CC on my system.  CC opens fine when I open it with the Shortcut.  But when I try to open a tif file on my desktop, the default program is CS6 and not CC.  So I try "open with and CC is not listed.  So I go to browse and find the Photoshop CC.exe icon under programs and choose it, I can't get it to show in the list.  I want to make this my defalult program and it won't work.  Help please.
    Thanks,
    Matthew Kraus

    I've had the same issue on Windows 7 64 bit. If I try to set file associations Windows simply does not recognize Photoshop CC. I browse to the .exe file, but it does not work.
    After I removed PS CS 6 all the file types reverted to the default program. Now the only way I can open a file in PS CC is to use File > Open inside the program.
    Bridge CC does not find Photoshop CC either so that will no longer work. It makes Bridge worthless since there is no way to open anything in Photoshop.
    13 days this is here and not a single answer? Are we the only two?

  • Airdisk falling asleep and not waking up

    what i thought might be a partitioning error/issue might be another thing altogether... let's start from the top. lots of random details follow, but something might be the kicker.
    i have an older AEBS (non-dual-band, non-giga-bit, circa 2007) in another room (garage -- with all of the other panels, switches, etc.) that distributes a signal to the whole house -- specifically to two airport express base stations (delivering music, printer sharing, etc.). the AEBS is sending out a G/N signal (for iphones, network cameras, etc.) and one of the expresses is sending out an N-only (for my macbook).
    the purpose of the AEBS is three-fold. (1) to provide wireless connectivity (2) to serve as a conduit to a backup airdsk for (a) general computer/home theater backups and (b) a consistent repository for a network (security) camera feed fed through "security spy" via a mac mini (home theater hub) which is hard-wired to the network via whole-house ethernet (belkin hub in the garage ties it all together). the camera itself is wireless (G-speed).
    over the past few weeks, i've been getting very poor throughput on the wireless network -- speed bumps back up (from <1bps to >20mbps) when plugged into the ethernet network (as viewed through speakeasy's speedtest).
    ok. the issue is that the new 2TB lacie harddrive is going to "sleep" and not waking up. it works fine for about 1/2 hour after hookup or "hard" wake-up (restart AEBS/drive).
    previously (as few as 5 weeks ago, i had a smaller lacie drive (1TB) serving the same function flawlessly.
    so... is this new airdisk issue due to:
    -- the AEBS not liking the 2TB size?
    -- the AEBS giving signs of failure (esp. with the network issues noted above)
    -- is the new lacie drive either (a) a DOA-failure or (b) doing its job by falling asleep (if so, it'd be a new 1TB>>2TB feature)...
    -- user error
    -- something completely random...
    thanks for any wisdom you can lend...

    I have pretty much the same setup with the same model AEBS and I get the same problem with a 2TB Western Digital drive plugged in. I solved this problem a month ago by updating my system to Snow leopard and updating firmware to the base station and rebuilding pretty much the whole network. But it came back this weekend. Is driving me crazy!
    (Side note: I also use that drive as a wireless Time Machine backup but can only get it to work reliably with my wife's Macbook not my own- which actually worked for a weekend but then decided that was enough.)

  • Connecting kurzweil sp88 to GB I want to connect my Kurzweil sp88 to GB. The Kurzweil has a baffling array of buttons and possible MIDI channels. It also has the old style MIDI plug ins. I've got the MIDI out connected to my MacBook Pro via USB adapter.

    I have my Kurzweil connected to my MacBook Pro via an adapter (old style MIDI from Kurzweil to USB adapter connecting to Mac). The Kurzweil has a baffling array of buttons and possible MIDI channels. Can anyone please tell me which of the channels I should use? Also, should I leave the MIDI In cable out of the Kurzweil? Thanks for as detailed an answer as possible. If you like you can respond directly to me at [email protected]

    First of all I do not own this keyboard. But a quick look at the manual (found on the internet) says that when first powered up the SP88 is in Internal Sounds mode. Meaning you hear the sounds selected when playing the keyboard. It also stated that the default Midi Transmit Channel is Midi Channel #1.
    Looks like you would need to go to the SP88 Keyboard's MIDI SETUP and simply select LOCAL OFF. Now the keyboard should be ready to transmit Midi Out only and no internal sounds should be heard.
    Next you may or may not need to do this but you might need to go into the Utilities Folder found in your Applications Folder on your Mac and double click AUDIO MIDI SETUP the keyboard Icon. Figure #1 below.
    Next you need to make a physical connection from the Midi Out of the SP88 to the Midi In on your Midi Interface. Figure #3 below. You may need to Click on Add Device first. Figure #2 below.
    In the examples shown below I have a Yamaha Electronic Drum Kit that is Midi Out only... not USB out. I had to plug a Midi cable from the Midi Out Port on the back of my Drum Module to the Midi In Port on the back of my Motu 828 Audio Inferface which is connected to my Mac. Next I created the Audio Interface and Drum Module "Devices" as mentioned above.
    I then double clicked on the Drum Module and made my Midi Out Selections. Figure #4 Below. And once it was setup and the icons closed I used my mouse to draw a virtual cable connection from the Drum Module Out to the Audio Interface In. Figure #3 below. This is how I got my Midi Devices to talk to one another.
    Once you have made your setup as I have outlined create a MIDI Instrument Track in Garageband, select an instrument for example a Piano then Record Enable that track in Garageband and see if you now hear what you are playing. In this example the SP88 is a Midi Controller only and you will only hear sounds selected in Garageband which is what you want.
    Keep in midi your setup may be different than mine. You can keep your SP88 Keyboard on the default Midi Channel #1. That would be a good place to start. Garageband receives Midi on all channels.

  • Why is Merge into single pdf using InDesign CS3 and not CS4 ?

    I'm new to this so the question may be trivial, but it beats me:
    I've created some InDesign files in CS4 and want to combine them into one PDF. So I opened Acrobat 9 Pro and
    navigated to "Merge files into single pdf". I chose the CS4 InDesign files to Add and clicked the Combine Files button.
    BUT, this starts up InDesign CS3 and not InDesign CS4 and returns a pop-up saying "unidentified error".
    Why is starting CS3 InDesign and not CS4, and what is the "unidentified" error ! ?
    As background I intially installed CS3 and then updated to CS4, leaving the CS3 applications intact. When I initially
    bought CS3, just before CS4 was released I may have created pdfs from InDesign as an experiment, but it is possible I have not done this
    since upgrading to CS4.
    Thanks for any help

    Thanks Michael, I was not aware of quality issues. Actually this is not really significant for my usage this time. What I'm doing is just using ID to capture notes/images/links etc in several free format ID documents. I then planned to merge them quickly into one pdf using Acrobat. I can easily shuffle the file order around to create a handy portable pdf reference document with the Merge feature.
    Doing something similar from ID seemed to me to require me to create pdfs for each ID doc and them to merge them in Acrobat. I did start to write a simple script to do this in ID, but I then realised that I wanted the ordering to vary and the ID files would likely to change. Then I found the merge and bingo, that solved it..... Well it solved it on another CS4 installation that had never seen CS3, but not on my machine which had been upgraded from CS3.
    I tried looking in the registry for obvious entries that might point Acrobat to use ID CS3 rather than CS4, but couldn't spot anything. I wonder if there is something buried in there ?
    Thanks again for helping
    Regards.

Maybe you are looking for

  • MDB and Trasaction problems...well sort of

    OK, I've got this MDB that gets messages off of Queue A, does some work and then sends a response to Queue B, where something is listening. This work flow works very well for me. What happens when something goes wrong? I'm using container managed tra

  • Substitution for Cost Center

    Dear all, I need to use substitution for cost center in some business scenario. Because FI document is automatically created by SD MM side, so cost center maynot be filled in if this account is configured for default accoun assignment in OKB9. Now, I

  • StartUp Plug Missing

    Hello Experts   I am getting StartUp Plug Missing Error.   actually i add two window in one component and after deleting first one i am getting this error. Please Help Me.

  • Is it possible to remove leather styling in new iCal?

    Hi, I waited for new iCal so much, but now I just can not use it, it makes me sick to look at the top bar of iCal where you can see LEATHER styling. Is it possible to remove that? thank you

  • Sidechaining sculpture

    i want know how can i use scuplture to sidechain onto an audio track, i have this guitar riff that is in audio track but i want to use the sounds and fx of sulpture to mimic the riff instead of the original recording, please help! thanks