JFrame singelton problem - creates new frames

Hello,
I'm trying to program a card game where the main window is a singelton JFrame which consists of several cards (custom-created abstract sublass of JLabel) and a placeholder for a bigger icon. When the user hovers their mouse over any card it should set the icon of the bigger icon in the frame, and when the mouse exits it should revert back to the standard icon. Any of its subclasses call the abstract method in the card class first before they move on to their own implementation. My problem is, that every time I do this, instead of setting the icon, it just creates hundreds of new frames. I presume this has something to do with the frame being a singelton? Any help would be greatly appreciated.
The GUI singelton part:
private static GUI instance;
public static GUI getInstance()
     if (instance != null)
          return instance;
     else return new GUI();
}The Card class:
public abstract class Card extends JLabel implements MouseListener */
     public ImageIcon icon, fullicon;
      * When the mouse hovers over the card, put the full icon into the top-right
      * spot of the GUI.
     public void mouseEntered(MouseEvent e)
          if (e.getSource() == this)
               GUI.getInstance().bigicon.setIcon(fullicon);
      * When the mouse has left the card, put the regular card backside icon into the
      * top-right spot of the GUI.
     public void mouseExited(MouseEvent e)
          if (e.getSource() == this)
               GUI.getInstance().bigicon.setIcon(GameConstants.BACK_ICON);
     }Example of a subclass:
public SubCard()
     addMouseListener(this);
* When the mouse exits the card, put the regular card backside icon into the
* top-right spot of the GUI and remove all Damage Counters and Energy Card icons.
* @Override mouseExited in Card
public void mouseExited(MouseEvent e)
     super.mouseExited(e);
     GUI.getInstance().energyPanel.removeAll();
     for (int i=0; i<14; i++) {
          GUI.getInstance().energyPanel.add(new JLabel(new ImageIcon("icons/blank.gif")));
}Edited by: pg-robban on Apr 12, 2009 11:31 AM
Edited by: pg-robban on Apr 12, 2009 11:35 AM

Just so you know, the general way to implement a singleton is like this.
private static GUI instance;
public static GUI getInstance()
    if (instance == null)
        instance = new GUI();
    return instance;
}

Similar Messages

  • Problem creating new sites. The formula refers to a column that does not exist

    Good morning,
    I have a problem creating new sites in my development environment. We have a template which works properly when we create new sites with it. However, when we add one new content type in the site created and save it as a new template, we can't create new sites
    with this template. The error log is that there are one problem in one column [The formula refers to a column that does not exist.  Check the formula for spelling mistakes or change the non-existing column to an existing column]. 
    I have opened the wsp template with visual studio but I can´t discover what column is the problem because the log only refers to the feature (ListInstances).
    Anybody knows how to find my problematic column?
    The error is:
    Feature Activation: Threw an exception, attempting to roll back.  Feature 'plantilla Llave en Mano 20141222 v2ListInstances' (ID: '6c61a3bf-3c51-4064-958b-d154729233e7').  Exception: Microsoft.SharePoint.SPException: La fórmula hace referencia a una
    columna que no existe. Compruebe que la fórmula no tiene errores ortográficos o cambie la columna que no existe por otra que exista. ---> System.Runtime.InteropServices.COMException (0x81020057): La fórmula hace referencia a una columna que no existe. Compruebe
    que la fórmula no tiene errores ortográficos o cambie la columna que no existe por otra que exista.     at Microsoft.SharePoint.Library.SPRequestInternalClass.UpdateField(String bstrUrl, String bstrListName, String bstrXML)     at Microsoft.SharePoint.Library.SPRequest.UpdateField(String
    bstrUrl, String bstrListName, String bstrXML)     --- End of inner exception stack trace ---     at Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionListInstances(SPFeaturePropertyCollection props, SPSite site,
    SPWeb web, Boolean fForce)     at Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionElements(SPFeaturePropertyCollection props, SPWebApplication webapp, SPSite site, SPWeb web, SPFeatureActivateFlags activateFlags, Boolean
    fForce)     at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, SPFeatureActivateFlags activateFlags, Boolean fForce)
    Thanks in advance

    Hi Enrique,
    According to your description, after added a content type into the new site and save the site as a template, there is an issue when creating another new with the newly
    site template.
    Based on the error message “The formula refers to a column that does not exist…”, seems that it would be an issue of a Calculated column in the content type you added,
    please go through all the Calculated column in that content type to see if the formulas all work well.
    Feel free to reply if there any progress.
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • Problem creating new reports in 11.1.1 - still retains prior reports POV

    I have a problem creating new reports in 11.1.1 - it still retains prior reports POV. Example - I create one report - which shows "all locations". I then want to create another report, with a different POV, specific for just one location "North America". If I try to start with the original report and change the POV, the older reports default to the newest reports POV. I tried saving the grid with a different name, I tried creating a report from scratch (not using any prior reports, objects or grids) and I still get the same result. I also tried to use a new database connection - still no luck.
    Any suggestions? Am I missing a critical step?
    Going forward, what is the best approach to take to create several reports, with differing POVs? (example, the period and fiscal year may differ, or a location may differ). I want the reports to run, without using one report and chagning the POV each time.
    Thanks,
    Linda

    I think this is on the same lines as this question > HOW TO SET FR POV PER REPORT, NOT PER CONNECTION ?
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Windows 7 Home Premium problem creating new user account

    I am unable to create a new user account on my Windows 7 Home Premium computer. I have 3 accounts on it already, two are adminstrators, and just trying to add a fourth one (standard user).
    I go to User Accounts, click Create new account, give it a name, keep Standard user checked, and press Create Account. The account appears to get created and shows up on the User Accounts screen, though it shows that it is password protected already, even
    though I didn't have an opportunity to give it a password yet. I can manage that new user account and delete the password, and it then shows up on User Accounts as not having a password.
    When I try to log on as that user from the main logon screen, it prompts me for the password (if I have specified one), but it doesn't accept the password (I've tried defining and using various ones), and I get the message "The user name or password is incorrect".
    If I don't define a password for that account, when I click on the account button to logon, I get that same error message immediately.
    I also noticed that C:\Users doesn't include the new user account folder there. Don't know if that should've been created at this point before logging on for the first time. I also noticed that there's a "Default User" folder that has a lock on the folder
    icon, and I'm not able to open that folder (says it's invalid). There is a "Default" folder there with some content in it and I am able to view it. Don't know if either of these folders act as templates for new users.
    At some point months ago I did have a profile problem with one of the existing accounts, and had to follow some suggestions on repairing that user profile. Don't know if that perhaps has complicated things. The 3 existing user accounts are working fine.
    Any tips on what I can try to get a new account established?
    Thanks, Chuck
    Chuck Mastrandrea

    I am unable to create a new user account on my Windows 7 Home Premium computer. I have 3 accounts on it already, two are adminstrators, and just trying to add a fourth one (standard user).
    I go to User Accounts, click Create new account, give it a name, keep Standard user checked, and press Create Account. The account appears to get created and shows up on the User Accounts screen, though it shows that it is password protected already, even
    though I didn't have an opportunity to give it a password yet. I can manage that new user account and delete the password, and it then shows up on User Accounts as not having a password.
    When I try to log on as that user from the main logon screen, it prompts me for the password (if I have specified one), but it doesn't accept the password (I've tried defining and using various ones), and I get the message "The user name or password
    is incorrect". If I don't define a password for that account, when I click on the account button to logon, I get that same error message immediately.
    I also noticed that C:\Users doesn't include the new user account folder there. Don't know if that should've been created at this point before logging on for the first time. I also noticed that there's a "Default User" folder that has a lock on
    the folder icon, and I'm not able to open that folder (says it's invalid). There is a "Default" folder there with some content in it and I am able to view it. Don't know if either of these folders act as templates for new users.
    At some point months ago I did have a profile problem with one of the existing accounts, and had to follow some suggestions on repairing that user profile. Don't know if that perhaps has complicated things. The 3 existing user accounts are working fine.
    Any tips on what I can try to get a new account established?
    Thanks, Chuck
    Chuck Mastrandrea
    I agree with the same problem and the answer below did not work either.  I tried changing permissions to Users directory and that did not work either.  I even tried creating the directory name of user I wanted to install and that was recognized and
    being used, but will not start a user directory for new user.

  • Problem creating new ABAP Technical System in SLD

    I newly installed a ECC 5 IDES system (ABAP + JAVA) on my computer for ABAP and Webdynpro learning.
    I got problem when I try to create new ABAP Technical System in SLD.
    I put my steps of installation here so you know my full story.
    1. Install Central Instance (Non-unicode);
    2. Install Database Instance (Non-unicode);
    3. Install Java add-in on ABAP;
    4. Configure the HTTP connection parameters in J2EE Engine Visual Administrator
    All of the above steps are successful.
    Now my Webdynpro application need to access a Function Module, so I want to create a JCo connection in Webdynpro Content Administrator, but both application server and message server are not available, so I can't create any connection.
    I go back to SLD to register ABAP Technical System step by step below:
    1.      Choose Home ® Technical Systems.
    2.      Choose New Technical System.
    3.      Select the AS ABAP radio button.
    4.      Choose Next.
    5.      Enter system details (Installation number, host name).
    6.      Choose Next.
    7.      Enter message server and central application server details.
    8.      Choose Next.
    9.      Choose Next.
    10.    Add New Client 800, leave logical name blank, click Add.
    11.    Choose Next.
    12.    Here the system says 'No product available', the whole effort make no sense.
    I tried every possible settings, but at step 12 it keeps telling me 'No product available'.
    This is the problem I want to fix.
    Can anyone help me?
    Thanks a lot in advance.

    hi,
    use th following thread,
    No products installed while adding a Technical ABAP System in the SLD.
    Regards
    Jayapriya

  • Problem Creating New Client in SAP NW2004s ABAP+JAVA LINUX

    Hi,
    I installed successfully NW2004s dual stack on linux vmware (SUSE10 enterprise server). This stack give me two client by default, 000 and 001. System gives me default user sap* and password: sapn4sadm
    I want to implement the process for BW enabling, and I want to create New Client for it. I have been used SCC4 to create a new client by logging on with the Client 000, but the problem start, when I log-on with the new client.
    Client: 002
    User: sap*
    Password: pass
    I have tried system default password of sap* , but that also dosen't help.
    It doesn't work, I also try RZ10 to change the value of login/no_automatic_user_sapstar = 0, but I don't find any profile , when I click on the profile field, i get the message "Profile not found". I am not figuring out where I am doing wrong.
    How can I success to create a new Client in which i could log on with sap* user. Please Help me
    All  yours help would be highly rewarded.
    Obaid.

    In order to edit profiles In RZ10, you must first import them.
    Menu: Utilities --> Import Profiles --> Of Active Servers
    After this you can add your parameter.
    One alternative is to edit the profile directly with vi, restart the system, do all client copy tasks, remove the parameter with vi, restart the system again and then import the active profiles.
    the profiles are located in directory
    /usr/sap/<SID>/SYS/profile
    and the filename is something like this
    <SID>_DVEBMGS<instancenr>_<hostname>

  • Having problems creating new playlists...

    When I get on iTunes i get a message saying The songs on the ipod cannot be updated because all of the playlists selected for updating no longer exists...but i have tried to create new ones and i still recieve the same message
      Other OS  

    Are you on a Windows PC or a mac? Have you tried recreating the library? http://docs.info.apple.com/article.html?artnum=93313

  • Problems creating new project and ringtone

    Hello everyone. I recently tried to create a new ringtone using GarageBand v5.0.2 and I ran into a problem. I clicked on iPhone Ringtone on the left hand side but there's nothing on the right and when I click on the Choose button, nothing happens. So I tried to create a new project instead. I clicked on New Project on the left, nothing shows up on the right, and when I click on Choose, nothing happens. Learn to Play, the Lesson Store, and Magic Garageband all seem to be working okay. So does Recent Projects.
    Any thoughts as to why this is happening to me? Or offer up a solution, maybe? Thanks in advance.
    -Bruce

    Never resolved

  • Problems creating new Web Dynpro ABAP application

    All,
    I am following this tutorial to create my first Web Dynpro ABAP application
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/fc/501b42b5815133e10000000a155106/frameset.htm
    In this tutorial I was asked to create a component as Local object.
    But after giving the name of the component, I get an alert saying
    "Object can only be created in SAP Package"
    When I confirm this, I was shown a "Create Object Directory entry" dialog box which asks for attributes like Package.
    And this box has Local Object button, when clicked I get the message "Test Objects cannot be created in foreign namespaces".
    I found some other article through Google
    http://www.octavia.de/fileadmin/octavia_files/content_bilder/Hauptnavigation/SAP_NetWeaver/WebDynpro/Web_Dynpro_Part_I.pdf
    According to this, I tried to give $TMP as Package. But still have the same error
    "Test Objects cannot be created in foreign namespaces"
    Where am I and what should I do to create a new project?
    Thanks.

    Thanks Abinav.
    My problem is with naming convention only. Component name starting with Z solved my problem.

  • Problem : create new role

    Hi,
    I'm using webservices to create a new role in OCS.
    It' OK to create the but I have a problem when I try to add some capabilities to this role.
    I use this code.
    NamedValuesList nvalues = new NamedValuesList().addValue(Attributes.NAME, "SYSDOC PROJECT MANAGER");
    Item item = getConnection().getDomainManager().getDefaultDomain(null);
    Item role = getConnection().getSecurityManager().createRole(item.getId(), nvalues.toValueArray(), null);
    nvalues = new NamedValuesList().addValue(Attributes.ACCESS_LEVEL, FdkConstants.CAPABILITY_DISCOVER);
    getConnection().getSecurityManager().updateRole(role.getId(), values.toValueArray(), null);
    And the returned exception is :
    oracle.ifs.fdk.FdkException: ErrorCode = ORACLE.FDK.ParameterError;
    DetailedErrorCode = ORACLE.FDK.InvalidAttribute; ServerStackTraceId = ; Info[0]
    = {ACCESS_LEVEL = 1}; Entries = null
    Thanks.
    K. HAMDOUNI

    Hi,
    It is not the problem because NamedValuesList is an utility class :
    ===========================================================
    public class NamedValuesList extends ArrayList
    public NamedValuesList() {
    super();
    public NamedValuesList addValue(String name, Object value){
    add(new NamedValue(name, value));
    return this;
    public NamedValuesList addValue(String name, long value){
    return addValue(name, new Long(value));
    public NamedValuesList addValue(NamedValue namedValue){
    add(namedValue);
    return this;
    public NamedValue[] toValueArray(){
    return (NamedValue[]) toArray(new NamedValue[0]);
    =======================================================
    Then this code :
    addValue(Attributes.ACCESS_LEVEL, FdkConstants.CAPABILITY_DISCOVER);
    do the same thing as
    addValue(Attributes.ACCESS_LEVEL, new Long(FdkConstants.CAPABILITY_DISCOVER));
    Just one question: is this functionality(customize roles) implemented in OCS10g 10.1.2 or not?
    Thanks.

  • Problem Creating New Data Server

    I'm new to ODI and I'm running into a problem with creating a Oracle Data Server for a new project I created. I right click on Oracle under Topology->Physical Architecture->Technology and nothing happens. If I expand oracle and right click on Datatypes, Actions, or Index Type the right click menu items show. Any idea why they won't show for Oracle?? I've tied this on a number of other technologies and get nothing there either.
    Please help!
    AJ

    This is installed on my home desktop so no administrator to go to. I'm using the supervisor account to log into the repository.
    Here's more information on my install:
    Installed on Win 7 64bit with generic ODI 11g install
    Oracle 11g with the master/work repositories created
    Installed ODI with only the Developer Install (ODI Studio, ODI SSK) option
    Any help is appreciate as I seem to have hit a wall with this.
    AJ
    Edited by: user1970745 on Sep 21, 2011 8:54 PM

  • Fixed one problem created new one

    I had a problem with my iphoto. Every time I tried to open it it would start to load my library and then quit, and give me an error message saying that iPhoto quit unexpectedly. This happened for a couple of months, and I haven't been able to use it. Finally i found a thread in the discussions where someone had the same problem. They were told to erase their existing library file, I tried that and now my iPhoto opens, the problem is that there aren't any pictures in it. I still have all of my pictures on my hard drive, I just can't figure out how to get them all back into iPhoto. I tried to open them with iPhoto, and it wouldn't let me do it, but even then, I would have to open them one at a time, is there any way that I can get my photo's back, and a way that I can do it without having to open every single one of them?
    Thank you.

    Hi Gabe,
    Did you do it this way?
    Close iPhoto
    Rename your messed up iPhoto Library to "iPhoto Library_old"
    Drag this library to your desktop
    Hold down the Option key and launch iPhoto
    This is the window you will get
    Create a new library or choose a library to open
    Choose to create a new library
    Once this new empty library is open it is time to import the images from your old library
    Go to File>add to library
    Navigate to the old library on your desktop and highlight it in the window, then click the "open" button.
    iPhoto will start importing the images from your old library
    This is what to expect:
    Your images will be imported in nice dated rolls. (make sure your view is set to sort by rolls to see it) There are a couple of caveats to this. You will get rolls named "Originals" These rolls will contain your video clips and your original images that you had edited. If you had RAW files they would be in those rolls too (I don't do RAW, so I don't know for sure) Delete what you don't want from those rolls. You will also get the jpeg pointer files to your video clips imported. They will just be jpegs and will not point to the video clips anymore as iPhoto made new ones when the clips were imported again. You can delete those. they should be in a roll right next to the newly imported video clips so they are not hard to find. The thumbnail files don't get imported as iPhoto makes new ones when the images are imported.
    Once all you images have been imported, check through the library and make sure everything looks ok.
    You can now start making your Albums, and do your keywords or any other organizational steps.
    You can also delete the old library on the desktop.
    It is also a good time to backup this new library to CD/DVD by burning the iPhoto LIbrary folder in the Finder, or copying the iPhoto Library folder to an external drive formatted for Macs, or copying the iPhoto LIbrary folder to an iPod.
    Good luck!

  • OS X Server Web Server Problem Creating New Domain

    I am running Mac OS X Server version 3.0.2 and added a new domain (website), like www.example.com, but my own.
    Everything seems to work fine.
    But when accessing the website it says the following:
    "Forbidden. You don't have permission to access / on this server."
    Who Can Access: Anyone
    What shall I do to change this?
    Sincerely,
    Andreas

    Thank you again!
    What puzzles me, is that we launching Terminal.app and stepping to the folder "/Library/Server/Web/Sites/Data/mydomain.com" and do a ls -al, it looks like this:
    drwxrwxr-x  18 root          admin    612 15 Jan 12:24 Default
    That is the Default site which I could access via internet when I enabled it at first.
    The same is set for mydomain.com that I created as a new web site (domain) in the Web Server, and the information is identical with the Default one, with one exception, the permissions. The permissions for mydomain.com is as follows:
    drwxr-xr-x  13 root          admin    442 15 Jan 15:44
    Why would not the New web site work when it is the same user and group that has access, with the only exception of a w less on mydomain.com?
    I thought I would see _www or www above, but not at all. Isn't that strange?
    Sincerely,
    Andreas

  • Problem creating new data sources

    hi -- I've just created a file DSN data source (Microsoft ODBC for Oracle Driver), and in Crystal, have used the ODBC (RDO) data source type, pointing to the file DSN. (I'm accessing an Oracle 10g database on a Unix server.)
    The connection to the database is successful, but when I use the Database Expert to pick the actual object (eg table) that I want the report to access, I get the following strange results:
    Not all schemas are visible
    For the schemas that are visible, only stored procedures are shown. No tables, views, or anything else.
    When I create an Oracle Server data source, all schemas and their objects are visible. The report works fine.
    Can someone explain to me why the File DSN is not showing me all schemas and objects?
    Thanks,
    Carol

    All -- Thanks for your suggestions. I probably should have given you more information up front:
    - I've already updated the database using Set Datasource Location.
    - I've already verified that the database explorer is including views and tables
    and is not restricting based on LIKE.
    - I did as Sourashree suggested and created a system DSN -- it also only shows
    me the stored procedures.
    I have successfully created a non-ODBC data source just using the Crystal Reports
    data source type of Oracle Server.  It works just fine -- tables, views, everything I need
    shows up in the explorer. So, my question about the File DSN is really just academic,
    out of curiousity (I struggled with it so long I'd like to know why it doesn't work!).
    If you can help me out, that would be great. But I see no reason the Oracle Server
    data source won't meet our needs.
    Thanks,
    Carol

  • SRM 7, Problem creating new tab

    Hello,
    I am trying to add a new tab to SRM 7.0 SRM User Settings and I get this error.
    Object or set with GUID 00000000000000000000000000000000 does not exist
    Please help.
    Best regards,
    Chinnu

    Hi,
    We are also getting the same issue.
    Could you please let me know if you have any solved this issue.
    Regards
    Venkatesh P

Maybe you are looking for

  • How do I find my lost ipod touch

    I had my ipod before I got on the bus this morning, it was in my pocket. I sat down on the bus, and I didn't take it out of my pocket, there was someone sitting next to me, but she couldn't have taken it out of my pocket because of the way she was si

  • Selecting values into same internal table from 2 differrnt select statement

    Hi Friends, code : types :    begin of ty_bsad,      augbl type bsad-augbl,   end of ty_bsad. begin of ty_bsad1,      augbl type bsad-augbl,      belnr type bsad-belnr,   end of ty_bsad1.   select augbl            from bsad           into table it_bs

  • Using variables in Illustrator

    Hi, I am trying to create templates which I can re-use for wireframing purposes, and I'm trying to find similar functionality as in OmniGraffle, where I can define generic fields, such as "Author", "Copyright" "Date", or "Description", and then inser

  • DNS name resolution ignores search domains ??

    I have a DNS search domain specified in network prefs for ethernet (and a domain picked up from DHCP).  But these appears to be ignored both in apps  and on the command line.  I find I have to type the fqdn which is a pain. Looking at /etc/resolv.con

  • Is there a 3rd party app to organize photos in camera roll?

    Thanks!