JOptionPane inputdialog, dealing with Cancel problem

Hello,
I've read a lot about the cancel button of a JOptionPane,
but never found how to deal with my problem.
I want to show twice a JOptionPane which prompts for the player's name, and place those names in a TitledBorder around my two panels.
The problem is , when the user clicks on the Cancel button in the first JOptionPane, the second JOptionPane isn't showed anymore.
Here's a part of my code:
private String name1, name2;
private JPanel[] cardPlayers = new JPanel[2];
public Game(){
askNames();
public void askNames(){
        name1 = JOptionPane.showInputDialog(null, "name of player 1");
        if(name1.equals(null)||name1.equals(""))name1= "Player 1";
        cardPlayers[0].setBorder(BorderFactory.createTitledBorder(name1));
        name2 = JOptionPane.showInputDialog(null, "name of player 2");
        if(name2.equals(null)||name2.equals(""))name2 = "Player 2";
        cardPlayers[1].setBorder(BorderFactory.createTitledBorder(name2));
    }Any solution?
Kind regards

hi,
if you have not initialized panel than you might me getting an exception while setting border,
         cardPlayers[0] = new JPanel();
                      cardPlayers[1] = new JPanel();if the above is not the problem, there is one more problem in the code...the way you are checking for null..
use the following code..
            if(name1 == null || name1.equals(""))name1= "Player 1";
            cardPlayers[0].setBorder(BorderFactory.createTitledBorder(name1));
            name2 = JOptionPane.showInputDialog(null, "name of player 2");
            if(name2== null ||name2.equals(""))name2 = "Player 2";
            cardPlayers[1].setBorder(BorderFactory.createTitledBorder(name2));name2== null is ok
name2.equals(null) is NOT OK (will throw NullPointerException)
~Byju Joseph

Similar Messages

  • It says that "there was a problem connecting to the server". What's wrong with this, and how can I deal with this problem?

    I just got my new iPad Mini2, and when I choose "sign in with your apple ID", it says that "there was a problem connecting to the server". What's wrong with this, and how can I deal with this problem?

    1. Turn router off for 30 seconds and on again
    2. Settings>General>Reset>Reset Network Settings

  • How to deal with this problem while Flex Integration   SSH

    Error creating bean with name '_messageBroker': Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: flex/messaging/AbstractFlexSessionProvider……
    Caused by: java.lang.ClassNotFoundException: flex.messaging.AbstractFlexSessionProvider
    I have  exist project used  SSH ,and now need flex to be use in some new unint.
    I hava follow these step to write my code , please help me to pickup the misstake  i had token.
    (flex4.0  spring 3.6 strust2.2 **)
    1. download the Blazeds file  and spring-flex-core-1.5.2.RELEASE.jar
    (org.springframework.integration-1.0.3.RELEASE.jar also include)
    2. unpack the Blazeds copy the flex folder to WEB-INF 
    3.add the lib/*  to my project lib folder
    4.add some declaration in the web.xml
    5.new a flex-application-config.xml 
    ^^^^ and so on.  I don't know how  to deal with this problem!!!
    Waitting for help!

    The information you provided is totally useless for determining the problem.
    If it helps, I think the message you are getting is related to BlazeDS not being able to find the service class you are calling. You either have a typo somewhere, or you didn't set up a secure channel in your service config (I am assuming you meant SSL and not SSH).

  • How to deal with this problem?

    How to deal with this problem?
    We plan to use Oracle Coherence (In Memory Data Grid) for a large-scale application. In order to keep the database table data in Coherence caches, we will create all the corresplonding Java objects (entities) and construct the persistence system using JPA/EclipseLink+JDBC. In this way, any in-memory object update will be persisted to the corresponding database tables.
    The problem is that some existing application codes are updating these database tables directly now. If the direct-database-table update is not permmited in the persistence environment, we have to discard most of the existing application scripts.
    I want to know, in this situation, should I discard most of the existing scripts?
    Are there any other solutions?

    Allowing writes from both cache & DB is possible with its own set of issues.
    The main issue to consider is conflicts from updates on same record via both cache and DB. If your caches are write-through the conflict decreases - but then cache writes become slower. If your caches are write-behind potentially the older cache update will overwrite the latest DB update. Now you are back to Database 101 -- timestamps, versions, etc...
    If you use a DB trigger to initiate the resync request you might want to distinguish whether the update has come from the cache-store (in which case, you may choose to do nothing), or if the update was from the 'existing apps', etc...
    If you choose to inject the resync logic at the application code level - you have the usual sourcecode issues - can you modify the code, is all the DB code localized, what options do you have to link with Coherence functionality (DLL, external proc, webservice, etc), etc... Naturally though, if you have to make substantial changes to signal a resync....you might consider taking the extra step and change the code to write to the cache.

  • Since I upgraded to Moutain Lion I'm dealing with wifi problems : no connection or random connection

    Since I upgraded to Moutain Lion I'm dealing with wifi problems : no connection or random connection. With  OS X Lion wifi was OK.

    So, Darrall, it seems to be fixed.  Mind you, this has happened through a seemingly unrelated, but hopefully replicable sequence of events.  You be the judge.
    I went to my other login account, which as it happens is also an admin account.  Voila, the secondary click worked fine.  So I returned to my primary account, where I did the following:
    First, I unpaired the trackpad.  then I remembered I needed something to move the mouse with, so I re-paired the magic mouse I'd had before.  I thought I'd turned off the trackpad, but apparently not, so the computer re-paired it automatically. None of this had any immediate effect, as you'd imagine.
    Then I went to Mission Control in Preferences. There, I deselected "Show dashboard as a space", and in the hotcorners, I deselected Mission Control from the bottom left, where it had been. I didn't replace it.
    Now, my secondary click works. Uh huh. I was suspicious that it might have more to do with Mission Control and/or Dashboard than the trackpad, only because I'd beaten that horse till my arm hurt and this was all I could think of. 
    Never did I imagine this would get fixed short of creating a new login account and somehow copying everything - since I didn't know what was wrong, I could easily have copied the error too - so I'm very pleased and relieved.  If you haven't fixed yours yet, try this.  Let me know what happens!

  • ITunes randomly stops playing purchases that have previously viewed on the same hardware. It has an error message about HD. How can this issue be resolved?  What information is available besides the "learn more" option that does not deal with the problem?

    iTunes randomly stops playing purchases that have previously viewed on the same hardware. It has an error message about HD. How can this issue be resolved?  What information is available besides the "learn more" option that does not deal with the problem?
    Many people have the same problem. However, there is little or nothing readily available to users. This problem has existed for two or more years. Does anyone have anything to offer about this disturbing problem?

    Thanks for the suggestion kcell. I've tried both versions
    9.0.115 and 9.0.124 and both fail with the policy permission error.
    I also tried with and without your crossdomain.xml file but
    with the same result. It looks like this file is intended for URL
    policy, instead of socket policy. Recently Adobe separated the two.
    When I run with the files installed on my dev PC, it does
    work, which makes sense because the flash player isn't loaded from
    an unknown domain.
    I did get one step closer. If a crossdomain.xml in the server
    root exists and the socketpolicy file is loaded from the app folder
    then the first two warnings disappear. The logs now show:
    OK: Root-level SWF loaded:
    https://192.168.2.5/trunk/myapp.swf
    OK: Policy file accepted: https://192.168.2.5/crossdomain.xml
    OK: Policy file accepted:
    https://192.168.2.5/trunk/socketpolicy.xml
    Warning: Timeout on xmlsocket://192.168.2.5:843 (at 3
    seconds) while waiting for socket policy file. This should not
    cause any problems, but see
    http://www.adobe.com/go/strict_policy_files
    for an explanation.
    Warning: [strict] Ignoring policy file with incorrect syntax:
    xmlsocket://192.168.2.5:993
    Error: Request for resource at xmlsocket://192.168.2.5:993 by
    requestor from https://192.168.2.5/trunk/myapp.swf is denied due to
    lack of policy file permissions.
    Which basically says, everything is okay, but you stay out
    anyway.
    PS: I found the XML schema files here:
    http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_02.html
    and the socket policy schema:
    http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd.
    UPDATE: When serving up the policy file on port 843 using the
    example perl script then the socket connection seems to be accepted
    and the connect succeeds. After that flex hangs trying to logon to
    the IMAP server.

  • I deal with a itunes update problem when i try to update i get coneection has timed out error! i had the same problem when i had vista.. yesterday i formated my pc but i still have the same prommblem. i dont deal with such problems on direct downloads.

    i deal with a itunes update problem when i try to update i get coneection has timed out error! i had the same problem when i had vista.. yesterday i formated my pc but i still have the same prommblem. i dont deal with such problems on direct downloads.i have this problem only with tunes. maybe my conection freezes for a sec idk

    Sorry I gave this a 'this helped me' but after a long struggle I found some ticked box somewhere from some unauthorised chrome extension blaaa....... the link you gave was great, not only did it confirm all the bad things google is supposed to be up to it provided a better browser. Cheers man.
    Anyone who find this; I disabled all extension in chrome. I then searched the word proxy in the settings section. A button came up, "change proxy settings" I clicked on it. Earlier it was greyed out as an extension was interefering.. It brought up a box with my own settings from my computer. Then I clicked LAN settings, then unchecked the 'Use a proxy server' button.
    P.S. If you're using chrome, bail, and dowload Komodo Dragon. It's virtually identical, but you're not tracked, and you can use chrome extensions, and you can quickily transfer your chrome preferences into it.

  • How can i deal with this problem

    For example, In my database, there are three records:
    field : a b c
    a.txt c:/a.txt adsfs
    b.txt c:/b.txt asdfsf
    c.txt c:/c.txt asfdsf
    Now I open one file b.txt to check the database whether have the same filename,filepath, hash value.
    the results display:
    The file: b.txt has not been registered
    The file: c://b.txt appears OK
    The file: b.txt has not been registered
    I want to do is to only shows the results of 'The file: c://b.txt appears OK'. I know the problem is the body of while(rs.next).
    is there any best way to conform to my demand
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url="jdbc:odbc:MD5";
    Connection connection=DriverManager.getConnection(url);
    Statement statement = connection.createStatement();
    String sql="SELECT * FROM MD5";
    ResultSet rs = statement.executeQuery(sql);
    while (rs.next()) {
    if (file.getName().equals(rs.getString("a")))
      if (file.getPath().equals(rs.getString("b")))
      if (m.equals(rs.getString("c")))
        jTextArea2.append("The file: " + file.getPath() +"appears OK"+"\n");
    else jTextArea2.append("The file: " + file.getPath() +"has been modified"+"\n");
    else jTextArea2.append("The Path for the" + file.getName() +"has been modified"+"\n");
    else jTextArea2.append("The file: " + file.getName() +"has not been registered"+"\n");
    rs.close();
    connection.close();
    }

    Why not add a WHERE clause to your statment to filter records having the name of the file in the first record. In this case you'd better use PreparedStatement and set the file name as statement parameter
    Because now you loop through the entire table for a thing you can deal with at DB level.
    And I agree with the others' remarks about those braces ;)
    Mike

  • Inability of the staff to deal with the problem in the phone

    I bought the experia z1 in February 2014 . The phone was supposed to be waterproof.  I used it while standing on a rock againt which waves striked and their were splashes of water. I was cautious that the guard of the charging port was closed.  After that the phone was working absolutly fine until it ran out of charge and den switched off. But when i charged the phone and tried to turn it on , the phone didnt switch on at all. I was also simultaneously also using a samsung galaxy s4 there which does not claim anything about being waterproof and is still working absolutely fine. I took my experia z1 to the service centre in jodhpur, india, where the the staff was extremely rude and non cooperative,  dey at first even denied dat experia z1 was a waterproof phone . Despite my repeated reminders no action has been taken. The last time i went there, they said they were going to send it to a higher centre as they were not authorised to open the set . I was waiting for the response and aftr 5 days when i called them again to know the progress i was informed that the set hasn't been sent to any higher centre at all, also then i was told that they cannot do anything about the problem. Pls look into the matter..

    Hi and welcome to the community! Since you're new please be sure that you have checked out our Discussion guidelines.
    I suggest that you raise this with your local support team to check status and how to proceed with this in the best possible way:
    http://support.sonymobile.com/global-en/contactUs/
     - Official Sony Xperia Support Staff
    If you're new to our forums make sure that you have read our Discussion guidelines.
    If you want to get in touch with the local support team for your country please visit our contact page.

  • Help with SOAP traces to deal with VC Problem

    Hi,
    I'm currently using CE SR 3 and am having trouble using a web service in VC. I've used the WS in the web service navigator and it works there but I'm missing something in the VC environment. I'd like to be able to see the actual SOAP request and response messages that are being used.
    Does anyone have an idea on which trace locations I can set to find this information.
    Thanks.
    Dick

    Hi Richard,
    Is it possible for you to elaborate a bit about the problem?
    There is a known limitation concerning web service consumption:
    Limitation 0120031469 1000108608 - Services that contain nillable structures with no fields cannot be consumed in Visual Composer.
    Can this be the case?
    Regards,
        Shai

  • Why is Skype not dealing with these problems?

    I can't connect to relatives with the new version of Skype and I see that countless other people have the same problem.  As this is a Skype site, how come Skype aren't responding to any of these complaints and advising us of a fix?

    because they are useless incompetent fools, these issues have been going on for years.

  • How do you deal with connection problems?

    All of a sudden I'm having major connection problems with DW. I have checked my FTP settings against Yahoo's specs since that's who I host with and I've also talked to my ISP. Neither Yahoo nor my ISP can figure out what the problem is. To my knowledge I haven't changed any browser or firewall settings, but I'm having problems uploading pages to my site. I CAN connect to my site and it uploads a few pages, but then loses the connection and has to reconnect. It's also running REALLY slow, like dialup slow. I don't get any other error messages beside the fact that the connection has been lost. I did notice something in the FTP log that says No anonymous logins accepted. Is that a Yahoo thing, ISP problem or DW problem? If anybody knows how to fix this please let me know a.s.a.p. Thanks in advance for your help!

    First, test out the FTP connection using a dedicated FTP client (FileZIlla/Transmit  PC/Mac respectively). If you can connect and upload/download succesfully using a stand-alone FTP clieny, that means it's a Dreamweaver problem. Possible solutions: check your site settings, recreate your site by defining a new site - Dreamweaver sometimes messes up the site definitions and recreating the site definition can sometimes fix it. Or just give up on using Dreamweaver's FTP services. To be honest, Dreamweaver's FTP services have always been a bit iffy in my experience. I typically do my uploading using a seperate FTP client.

  • How do I deal with my problem?

    When I want to buy gold from the game can not complete the purchase and show me this sentence
    (Your purchase could Not Be Completed
    for assistance, contact iTunes Support at
    www.apple.com/support/itunes/ww/)
    I tried many times but I can not
    And not just every game I can not purchase inside applications
    But when I buy a game or any application from Apple Store so I can.
    Notes: I own Visa account, effective and registered in my account
    Device: iPad Mini WIFI
    Thank you

    bobseufert you are right i contact itunes support at address and there is mr. david he help me with my pro thank you and thanks to mr.david.

  • When i try to connect my iphone to itunes it comes up with a message saying "itunes could not connect to this iphone, an unknown error has occured (0xE8000012) any ideas on how to deal with this problem??

    When i try to connect my iphone to itunes it comes up with a message saying "itunes could not connect to this iphone, an unknown error has occured (0xE8000012)
    i have recently bought  new laptop and downloaded/installed the newest itunes and this has happened.. any ideas?

    read
    Error -50
    Delete Storm Video, QuickTime, iTunes, then reinstall iTunes. See also KB TS1583for error -50

  • Can I use more than one AirPort Express to deal with access problems on my system?

    my house unfortunately has wall-boards which have a layer of tin foil  on  them, which is great when you are looking for cheaper heating bills, but is absolutely awful when trying to install Wi-Fi!

    Yes you can, you could either run cat 5 cable to each one and have them as seperate wii networks or do as I do and use the as range extenders.
    See http://www.apple.com/uk/airport-express/
    Extend an existing Wi-Fi network’s range.
    If you already have a wireless network in your home and want to extend its range,AirPort Express can help. Just place it in range of your primary base station — anAirPort Extreme, AirPort Time Capsule or another AirPort Express — and near the area where you want your wireless connection. Launch the easy-to-use AirPort Utility app on your iOS device or Mac, and you’re mere minutes away from long-range Wi-Fi enjoyment.

Maybe you are looking for

  • XSU attribute mapping error

    I've encountered an attribute mapping problem when using the Java OracleXMLQuery class in XSU (Oracle XML Developer's Kit for PL/SQL on Windows NT - 9i 9.2.0.1.0). As an example, take a look at the following object type containing one field whose nam

  • Scanning for virus messages

    I keep getting messages telling me that there is a problem and askingif I want to scan.  How do I get rid of these messages? Please help!!!!

  • Laptops do not receive DHCP IP address?

    Hi All, Iam using 4402-Controller and 1252 Access Points. The AP's are registered on the Controller and get an ip address but the laptops are not getting an ip address. The FWSM on the Core switch is configured as DHCP server with IP of 192.168.5.1.

  • What is Country of origin in Material Master?

    What is Country of origin in Material Master? what is its change impact to the business and business processes?

  • Assignment to Bases of Valuation

    Hi Gurus, when i rum simulation for leave Eancashment i can see below entry in my payroll log . 3 /001 Valuation  01                            128.59 to get that amount system will consider 4 allowences wage types . My questions is 4 allowences wage