I am stuck in getting this loop working properly for 6 hrs

               if (canCount == 1)
                    vcan1.setVisible(true);
                    canCount = 2;
               else
                    if (canCount == 2)
                         vcan2.setVisible(true);
                         canCount = 3;
                    else
                         if (canCount == 3)
                              vcan3.setVisible(true);
                              canCount = 4;
                         else
                              if (canCount == 4)
                                   vcan4.setVisible(true);
                                   canCount = 4;
                              else
                                   if (canCount == 5)
                                        vcan5.setVisible(true);
                                        canCount = 5;
                                   else
                                        canCount = 1;
          }     In the above code the canCount is the integer variable which starts with one when the frame is loaded. After that everytime a button is clicked, I want to show one label..again its clicked then i show next label ...till all 5 textfields are over....however it seems to be showing these labels ivariably
I have not been able to fugure out where and why....please help soon......before i get too frustrated...............which is really close..............
PLS HELP

Is this the behavior you're looking for?import java.awt.event.*;
import javax.swing.*;
class ButtonDemo {
    private JButton[] buttons = {
        new JButton("one"),
        new JButton("two"),
        new JButton("three"),
        new JButton("four"),
        new JButton("five")
    public static void main(String[] args) {
        new ButtonDemo().go();
    void go() {
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        for (int i = 0; i < buttons.length; i++) {
            buttons.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for (int j = 0; j < buttons.length; j++) {
if (e.getSource() == buttons[j]) {
if (j < buttons.length - 1) buttons[j + 1].setVisible(true);
if (i > 0) buttons[i].setVisible(false);
panel.add(buttons[i]);
JFrame frame = new JFrame("ButtonDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(panel);
frame.setSize(50,200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);

Similar Messages

  • What do i need to do to get this to work properly

             for(int i=0; i<6; i++){
             do {
                 JOptionPane.showInputDialog(null, "Enter guess" + " " + (i+1));
                 if (guess<1 || guess[i]>6 ){
                   JOptionPane.showMessageDialog (null, "That's not between 1 and 6, try again", "Invalid", JOptionPane.WARNING_MESSAGE);
              }while (guess[i]<1 || guess[i]>6);
    Basically, this compiles, but when i run this any input i put in gives the warning message. I need the warning message to happen only when the input is less than 1 or greater than 6. Anyway around this? I'm using an array of integers for the guesses as you can see.

    Having some code somewhere that changes the value of
    those array elements to be something other than zero
    would be a start.
    And getting the value from the JOptionPane would be a
    good bet. The showInputDialog returns a value so
    you're in luck.Do you mean I should change the value of i to something other than 0? I'm not too sure what you mean, I'm quite new to Java.

  • HT5731 i tried downloading a movie to my itunes and it successfully downloaded but will not let me play.  If i can't get this to work properly i would appreciate my money back.

    I recently rented a movie from itunes and it seemed to download successfully but when i try to watch it, it give me a blank screen.  The counter at the bottom of the screen doesn't move.  Someone please help

    To Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • Does This Site Work Properly For You?

    http://www.trickracing1.net
    Whenever I hit the back arrow in Safari3 or the main menu button on the "Blown Banshee" page I get a beachball and Safari3 unexpectidly quits...

    I tried all the usual stuff...(trash plist,reset Safari,repair permissions...) still does it. Just that one **** page though. Removed QT movies on page and republished, added them back and republished. No go for me. It works fine on all my friends' and family's Macs. I'm Stumped!!

  • I am using Hover for my email address and I can not get it to work properly

    I've changed the MX record to 10mx.hover.com.cust.hostedemail.com (Hover's recomendation) but it's still not working.
    How Can I get this to work properly?
    Thanks for the help!

    Hey KoobeP,
    I have performed a DNS look-up on the domain stormbluedesign.com and can see that the MX record you have added exists within our DNS: http://screencastmb.worldsecuresystems.com/img/2013-04-24_0949.png. However, this MX record is not pointing to any IP address which leads me to believe the MX record you added is incorrect.
    I believe the MX record you need to add is mx.hover.com.cust.hostedemail.com, with a priority of 10. Not 10mx.hover.com.cust.hostedemail.com. But as always, contact your mail service provider for confirmation on the records they require you to add.

  • HT1203 iTunes: How to share music between different accounts on a single computer - I tried to use the instructions to configure 2 different windows users sharing the same iTunes library.  I could not get this to work per the instructions.

    I tried to configure 2 windows users accounts using a single library per the instructions in HT1203.  My iTunes library is on an external drive.  I cannot get this to work.  Any suggestions?

    To give other users read-only access to your iTunes library, use the Sharing features of iTunes. Sharing works over the local network as well as on the same computer. See the built-in help for details.
    If you want to give full read/write access to more than one user, see the support article linked below.
    iTunes: How to share music between different accounts on a single computer
    There is a way to share the library without moving it to a secondary volume. If you really need to do that, ask for instructions.

  • I have purchased itunes match but the cloud will not load on my ipad 4.the only music that will show up is stuff that i bought from the itunes store.any ideas on how to get this to work?

    i have purchased itunes match but the cloud will not load on my ipad 4.it works on my iphone 5 & it originally worked on my ipad.the only music that will show up is stuff that i bought from the itunes store.any ideas on how to get this to work?

    On the MBP, in iTunes, switch to Song view and enable the iCloud Status column by pulling down View > View options and selecting the option for "iCloud Status." Close the small window. Look for any tracks that have a status of "waiting." If you see several of them disable iTunes Match while holding down the Option key. Quit iTunes, wait a few seconds, then open it again and turn iTM back on. Let it compelete the scan. Wait until all tracks that are "waiting" have a status of either "matched" or "uploaded."
    On the iPad, turn off iTunes Match then launch the Music app and let the contents clear out. Power cycle the iPad for good measure, then re-enable the service once all the tracks in iTunes have been processed.

  • My iPod Classic is seen by Windows but not by iTunes.  I have reset it, gone to disk mode and it won't show up in iTunes.  There appears to be music on it in a file called MUSICSAVE.  How can I get this to work with iTunes again?

    My iPod Classic is seen by Windows but not by iTunes.  I have reset it, gone to disk mode and it won't show up in iTunes.  There appears to be music on it in a file called MUSICSAVE.  How can I get this to work with iTunes again?

    1. Update iTunes to the latest version. Plug in your iPod. If iTunes still can't recognize it, then in iTunes in the top left corner click help> run diagnostics. On the box that comes up, check the last two things. Click next and it should identify your iPod.
    2. Click on your windows start menu. Type in "services". Click on it and when it pops up, on the bottom of it click on "standard". Now Scroll down to find "Apple Mobile Device" Right click it when you see it and click on "Start". When it has started, close iTunes and replug in your iPod and it should show up.
    3. Check the USB cable
    4 Verify that Apple Mobile Device Support is installed
    5. Restart the Apple Mobile Device Service and verify that the Apple Mobile Device USB Driver is installed.
    6. If you just want to add some photos, songs and movies from computer to your devices, you can use an iTunes alternative to do the job
    7. Check for third-party software conflicts.
    <Link Edited By Host>

  • I installed Lion 10.7.4.  Went to use Photoshop Cs and got a popup window.  You can't open the application Adobe Photoshop CS because PowerPC applications are no longer supported.    Is there a way of getting this to work or do I have to get the all new!

    I installed Lion 10.7.4.     Went to use Photoshop Cs and got a popup window.  You can't open the application Adobe Photoshop CS because PowerPC applications are no longer supported.    Is there a way of getting this to work or do I have to get newest version of all of my Power PC apps?

    Welcome to Apple Communities
    PowerPC applications are unsupported in newer versions. You can upgrade Photoshop or you can install Snow Leopard in a partition.
    1. Open Disk Utility (Applications > Utilities) and select your drive
    2. Go to Partitions tab, press + button, create a new partition and press Apply
    3. Insert the Snow Leopard install DVD and reboot pressing C key
    4. Install it in the new partition
    5. If you want to change boot, go to System Preferences > Startup Disk and select 10.7

  • I am synching my ipad and iphone with icloud. Events put in calendar go to the iphone, but if i enter an event on the iphone, it does not go to the ipad. What do i do to get this to work both ways?

    I am synching my ipad and iphone with icloud. Events put in calendar on ipad  go to the iphone calendar,, but if i enter an event on the iphone calendar, it does not go to the ipad. What do i do to get this to work both ways?

    OK Vicky, good clues...
    See if this helps...
    Open Keychain Access in Utilities, use Keychain First Aid under the Keychain Menu item, then either check the Password under that item, change it, or delete it and start over. See if there are duplicates, should be one for Incoming & one for Outgoing.
    Resetting your keychain in Mac OS X...
    If Keychain First Aid finds an issue that it cannot repair, or if you do not know your keychain password, you may need to reset your keychain.
    http://support.apple.com/kb/TS1544

  • TS3212 I updated my itunes and now when I try to send music to itunes it won't send to the folder I sent it to. What do i do to get this to work?

    I updated my itunes and now when I try to send music to itunes it won't send the music to the folder I sent it to. What do I do this get this to work?

    in the iPhoto preferences ==> accounts delete your e-mail account and reenter it
    OR
    IMHO the better solution is to set Apple mail as the email client in the iPhoto preferences
    LN

  • After updating to Firefox 5 my Realplayer Recorder is not working due to that add on not being compatible. How do I get this to work again?

    After updating to Firefox 5 my Realplayer Recorder is not working due to that add on not being compatible. How do I get this to work again?

    Blue
    It sounds like you restored from an old back-up.  Did you back-up just before your software update?  It will use your last one and if your last back-up was a ywear old then it will use that one.
    In general, if you are getting these messages on your iPhones select logout (when you get that Apple Id request) and then log back in with your newer ID.
    Sorry for your losses.
    Cheers

  • I am using Numbers on my iPhone5 and cannot get the app to do a simple (SUM) calculation.  It shows the formula correctly in the cell, but all I get for my long list of numbers to add is 0.  How can I get this to work?

    I am using Numbers on my iPhone5 and cannot get the app to do a simple (SUM) calculation.  It shows the formula correctly in the cell, but all I get for my long list of numbers to add is 0.  How can I get this to work?

    Oaky, at least we got that far.  Next step is to determine if all those "numbers" are really numbers.  Changing the format to "number" doesn't necessarily change the string to a number. The string has to be in the form of a number.  Some may appear to you and me as numbers but will not turn into "numbers" when you change the formatting from Text to Number. Unless you've manually formatted the cells to be right justified, one way to tell if it is text or a number is the justification. Text will be justified to the left, numbers will be justified to the right.
    Here are some that will remain as strings:
    +123
    123 with a space after it.
    .123

  • Facebook like button is not working, I have used the muse widget and created code from facebook. Does anyone know how to get this to work?

    Facebook like button is not working, I have used the muse widget and created code from facebook. Does anyone know how to get this to work?

    Hi connally25,
    Below is a link to a video tutorial on how to add a Facebook Log button, please check if you have followed the same steps to add the video.
    http://tv.adobe.com/watch/learn-adobe-muse-cc/adding-a-facebook-like-button/
    If you have followed the steps correctly and the button still does not work; here is a link to a forum thread which might help solving the issue:
    Facebook Follow Widget not working
    Regards
    Sonam

  • Where can I find the plugin to open camera raw files for Nikon D810 for Photoshop CS5.1? I've looked around the site but cannot get this to work.. Thank you.

    Where can I find the plugin to open camera raw files for Nikon D810 for Photoshop CS5.1? I've looked around the site but cannot get this to work.. Thank you.

    See for yourself which version of ACR is needed for that camera’s RAW files
    http://helpx.adobe.com/creative-suite/kb/camera-raw-plug-supported-cameras.html
    then check your version (Photoshop > About Plug-In > Camera Raw).
    Your version of Photoshop does not support that version of ACR.
    You could use the free DNG Converter.

Maybe you are looking for