Graphics plain 2D objects are not rendered while an action occurred!!!

Hi, I am designing a game in Swing. Currently I am designing the maze for this game. The maze is generated by using Depth First Search algorithm. In my main JFrame, I have some JPanel. One JPanel, named mazePanel contains the maze. There are some other JPanel also, which contains the JButton for controlling. Following is the mazePanel code.
import java.awt.Graphics;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
public class MazePanel extends JPanel {
    private MazeGenerator mazeGenerator;
    private boolean startNewMaze = false;
    public MazePanel() {
        setBorder(BorderFactory.createTitledBorder("Maze"));
        setToolTipText("This is the maze");
    public void addNewMaze() {
        startNewMaze = true;
        mazeGenerator = new MazeGenerator();
    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (startNewMaze) {
            mazeGenerator.generate(g);
            startNewMaze = false;
} There is one JButton, which calls the method mazePanel.addNewMaze() and set the Boolean startNewMaze to true. After setting the startNewMaze, maze should be generated. i.e. mazeGenerator.generate(g) is inside if() condition. Method mazeGenerator.generate(g) recursively draw the random maze. That is why I don’t want to run this method not more than once.
Up to this everything is looking fine. But while I am running the main JFrame and clicks on the JButton, maze is not rendered in the mazePanel. Sometimes when I minimize and maximize the JFrame, maze rendered (might be because of repaint() occur). Even if I comment mazeGenerator.generate(g) inside if() condition and put some g.drawString(). The string is not rendered while action performed (i.e.Pressing JButton).
Where is the problem? Please help.
Thank you.
Edited by: 889823 on Jan 28, 2012 3:28 PM (Code was not formatted correctly. I forgot to make use of tag)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

This kind of thing sounds simple but in reality is fairly tricky. I dealt with these kinds of situations for years while learning java, and still sometimes do.
You only posted a snippet of your code, from which we can't go through and debug what your problem is, but I would just say that this is the general pattern
1. Receive the event to create a new board. This can in reality be any event that will cause your UI to change
2. Do whatever processing you need to do to get your Component ready to be painted again. You can do short jobs on the UI thread. For longer jobs, look at the SwingWorker class
3. When you are done processing and ready to redisplay, call repaint() on your Component. Make sure after you call repaint() that any work being done on the UIThread finishes, so that this thread can then handle the repaint request
Edited by: tjacobs01 on Jan 28, 2012 1:37 PM

Similar Messages

  • Background images are not rendering while they are in all other browsers.

    Firefox is having problems with certain .jpg images that I have uploaded to a hosting service.
    (Ex: http://img838.imageshack.us/img838/3991/hbbgardenorangepop3.jpg)
    When you set this image as your web page's background image, the image will not be rendered. However, if you go directly to the URL, the image will be rendered (except in the Beta release, where the image won't even render when you go to the URL directly).
    However, if you go to ANY other browser, the image is rendered correctly (both when you go directly to the URL and when you use the image as your background).
    == This happened ==
    Every time Firefox opened
    == Today ==
    == User Agent ==
    Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.125 Safari/533.4

    I assume that you want to add that image as a background on web pages.
    How are you adding that background image?
    Are you using code in userContent.css ?
    If that is the case then please post the code, otherwise provide the steps so we can check what goes wrong.

  • System is not set to changable - objects are not changeable

    Hi Gurus,
    I am trying to open a query in the test system. while opening the query a error message is showing like: system is not set to changable - objects are not changeable.
    Kinly let me know how to solve this error.
    Due to this reason in my Plannin modler screen its showing that query is inconsistant,
    Regards
    Sajid khan
    Edited by: sajid.khan on Jun 22, 2010 9:35 AM

    Hi.
    In RSA1->Transport connection->ShftCtrl0 check whether you have any transport request connected.
    In addition ensure in "objects changebility" that you can change queries.
    Regards.

  • Some performance counter objects are not available for a 32-bit process on 64-bit versions of Windows Server 2012 standard

    When we try to gather performance counter information for a 32-bit process on a 64-bit computer that is running Microsoft Windows Server 2012, all our performance counter objects are not available with 32 bit perfmon application (C:\Windows\SysWOW64\perfmon.exe)
    I didn't notified any errors while registering our counter objects or while running Perfmon.exe
    Note: Same counter objects are available and working fine with Windows Server 2008 R2.
    for diagnostic our counters on WIN2012, ran command as follows:
     cd c:\windows\sysWOW64
     lodctr /Q
    I am able to see all our counter objects on response and infact all were shown as enabled, as shown below
    Appreciate quiclk response with solution or clues to diagnose it more details.
    Thanks & Regards,
    Sudhakar Rudra

    Hi,
    Thanks for your reply.
    I hope you understood our problem.
    same our system counter objects (ver x), we able to browse from Perfmon 32 bit app on Windows 7, Windows 2008 R2 (64bit) OS but not on Windows 2012.
    I am able to see all counter objects registered as follows (same at HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\HMI Alarm Class\Performance,
    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\HMI Alarm Class\Performance
    and
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HMI Alarm Class\Performance)
    Only difference I observed that "Disable Performance Counters" were set to 4 in Windows 2012 OS unlike other windows 7 64bit OS and there is no differnece for remaining all entires.
    I tried setting that "Disable Performance Counters" value to "0", but some how they get reset to "4", no luck..
    I think "Disable Performance Counters" value either "0", or "4", should not matter for browsing our counters with 32bit bit perfmon applicaiton.
    Do you see any issues of registry entries. ?
    On what basis perfomance monitor list few enabled counters?
    How can we add our counters manually to perfomance monitor?

  • Entity Attributes are not populating while creating EO using EO wizard.

    Hi,
    I am using JDeveloper version 10.1.3.3.0.3 and E-Business suite12.1.2.
    I am facing problem while creating EO using EO wizard.
    In Entity Object Editor Entity Attributes are not populating while creating EO.
    Please help me resolve this issue.
    Thanks & Regards,
    Sagarika

    Please ensure you click on Tables and Synonyms check box and select proper schema.
    Try to select the table from the list after this instead of writing as in 10.1.3 when we write table name it automatically selects from the list if it exists in the list.
    Thanks
    AJ

  • 0db* iobj are not available while installing 0sd_c03 update rules

    Hi all,
    i am facing this problem while installing the update rules of 0sd_c03.
    the following objects are could not be collected and they are not avialable in version d.
    all the objects are the nav attributes of 0sold_to
    they are 0sold_to_0dbareacod
    0sold_to_0dbctrycod
    0sold_to_0dbctrynam
    0sold_to_dbcustat
    0sold_to_0dbdistrcod
    0sold_to_0dbempbnd
    0sold_to_0dbhqduns
    0sold_to_0dblglgstat
    0sold_to_0dblocacod
    0sold_to_0dbregcod
    0sold_to_0dbsalnd
    0sold_to_0dbsectcod
    0sold_to_0dbmaktcod
    0sold_to_0db_mktcds
    How can i fix this issue?
    can anyone please throw a light on this one?
    Thanks & regards,
    V. Vijay

    hi,
    these objects are not available as a nav attr of 0sold_to ., while i am seeing in that iobj.
    it is showing only the 0dbduns_num only obj as a nav attr of sold_to. the remaining iobj are not showing..
    i have tried to install 0sold_to as a seperate also, but invain..
    these objects are not showing...
    any ideas..
    Regards,
    V. Vijay.

  • Command links are not rendering properly in panel collection toolbar facet

    Hi
    I am using jdev 11.1.2.3.0
    I added toolbar component to the toolbar Facet of panel collection component .
    Under the tool bar I added two command link components with name create and delete,
    the problem is at run time the buttons are not rendering properly,they are hiding,instead of links
    this symbol(>>) is displaying.
    On clicking the symbol,I am able to see the links,I used <af:spacer> after the links but not worked.
    what I have to do to render the links properly in the panel collection toolbar facet

    Hi Timo
    This is the code and I am using 11.1.2.3.0
         <f:facet name="toolbar">
                    <af:toolbar id="t1">
                            <af:commandImageLink icon="#{resource['images:create.png']}" text="Create" id="cbInsert">
                            <af:showPopupBehavior popupId="p1"/>
                        </af:commandImageLink>
              </af:toolbar>

  • Command links are not rendering properly in the toolbar facet of panel collection

    Hi
    I am using jdev 11.1.2.3.0
    I added toolbar component to the toolbar Facet of panel collection component .
    Under the tool bar I added two command link components with name create and delete,
    the problem is at run time the buttons are not rendering properly,they are hiding,instead of links
    this symbol(>>) is displaying.
    On clicking the symbol,I am able to see the links,I used <af:spacer> after the links but not worked.
    what I have to do to render the links properly in the panel collection toolbar facet

    Hi Timo
    This is the code and I am using 11.1.2.3.0
         <f:facet name="toolbar">
                    <af:toolbar id="t1">
                            <af:commandImageLink icon="#{resource['images:create.png']}" text="Create" id="cbInsert">
                            <af:showPopupBehavior popupId="p1"/>
                        </af:commandImageLink>
              </af:toolbar>

  • CIN: Items are not displayed while updating the RG1 Register using T Code:

    Hi Experts,
    Items are not displayed while updating the RG1 Register using T Code: J1I5.
    System is not showing any error message.
    Can any one explain to update the RG1 Register?
    Thanks
    Chandra

    Hi,
    dont go the table again and again . the table is updated at intial stage only for stock update but not when SAP is running.
    In day to day bussiness the flow is as follows:
    Production - MB31 - to Unres stock
    Sales - VL02n - PGI - to customer - i.e out of unres stock
    Every day u can run TC J1i5 once in a day as decided and update the register so all transactions which have happend in that day gets updated i.e both input and output.
    and this will happen every day.
    hence dont use table as it is only for intial data upload i.e just before golive.
    Hope i am clear.
    krishna

  • Some web fonts are not rendered

    When I visit some sites that use web fonts, the web fonts are not rendered. It does not render with the wrong font - the text is completely invisible.
    On other sites, web fonts work just fine, and I cannot understand why some web fonts work and some don't.
    Examples of non-working sites:
    http://blog.mailchimp.com/ (headers shown, article text missing)
    https://www.sbab.se/ (huge top header missing)
    http://onlinepizza.se/ (headers and button texts missing)
    Examples of working sites:
    http://www.google.com/fonts
    http://www.typetester.org/
    On the Network -> Fonts tab in the inspector, no downloads are shown on the broken sites. Is there a font cache that I can delete?
    I have tried uninstalling firefox, deleting all profiles and installing it again. Nothing changes.

    Works fine here on Linux.
    Right-click > "Inspect Element" > Font shows:
    *http://blog.mailchimp.com/ Copyright (C) H&FJ | typography.com (Whitney SSm B) & Copyright (C) H&FJ | typography.com (Whitney SSm A)
    *https://www.sbab.se/ SBABSansStencilBeta-Bold
    *http://onlinepizza.se/Stockholm/ MuseoSans-700
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Reload web page(s) and bypass the cache to refresh possibly outdated or corrupted files.
    *Hold down the Shift key and left-click the Reload button
    *Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
    *Press "Command + Shift + R" (Mac)

  • Flex SDK 3.2 : Unmarshalling issue : SOAP objects are not deserialized completely

    Hi everybody !
    I have a strange problem with SOAP deserialization in flex 3.2, and I thought this forum will be the best place to get answers ...
    When I try to fetch some objects (like the ones shown below), the XMLDecoder does not deserialize all the properties.
    In this case, it stops at the property named "rating". After it, all other data are lost.
    I've used the flex builder debugger to locate the problem, and this lead me to the following method in the XMLDecoder class :
    getApplicableValues(parent:*, valueElements:XMLList, name:QName,context:DecodingContext, maxOccurs:uint):XMLList:
    State of the variables, before the "bug" :
    The strange behavior appears after the five first properties had been deserialized correctly.
    At this step : startIndex = 5, and the next property to unmarshall is "user" (according to the MExpertNotes object mapping)
    the valueElement's list contains the following elements :
    to simplify the notation, I will write only the position in the list and the xml tag name (see the complete soap response for more details at the end of this post)
    (position, fieldName)
    (0, ID) -> inherited from MotocycletteObjectImpl
    (1,comment)
    (2, noteValidation) (a Bean, never returned by our service -> set to null)
    (3,noteValidationID)
    (4,rating)
    (5,timeOfCreation) -> inherited from MotocycletteObjectImpl
    (6,user) (a Bean, never returned by our service -> set to null)
    (7,userExpert) (a Bean, never returned by our service -> set to null)
    (8,userExpertID)
    (9,userID)
    (10,version) -> inherited from MotocycletteObjectImpl
    when it enters the for loop, at the first iteration the valueElements[i].name is equals to "timeOfCreation" and the name parameter is equal to "user".
    so this test : if (name == null || valueElements[i].name() == name
    || ((name.uri == "" || name.uri == null)
    && name.localName == valueElements[i].name().localName))
    returns false. The skipAhead variable is set to false (and i don't understand why). It stops iterating over the valueElementList, and so, skips all other properties.
    Is this a bug ? Does a workaround exists ?
    This affects many of our objects.
    Any help would be greatly appreciated.
    Best regards,
    Jules Pajot
    R&D engineer for Mikros Image
    www.mikrosimage.fr
    [EDIT] : My Message was too long, so I put the complete message here :
    http://docs.google.com/View?docid=dd6j35ft_38grb9c7cr
    PS : I apologize for my english wich is far from perfect :)
    As a reminder , the XMLDecoder class method ( line 2204 ):

    <div class=Section1><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'>The holidays are starting here.  The experts in the area may<br />already be away.  Please file a bug.  It might help if you can simplify your<br />test case to use an XML file that is local so we don&#8217;t need your server<br />connection.<o:p></o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'><o:p> </o:p></span></p><br /><br /><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><br /><br /><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span<br />style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Jules Pajot<br />[mailto:[email protected]] <br><br /><b>Sent:</b> Tuesday, December 23, 2008 9:05 AM<br><br /><b>To:</b> [email protected]<br><br /><b>Subject:</b> Re: Flex SDK 3.2 : Unmarshalling issue : SOAP objects are not<br />deserialized completely<o:p></o:p></span></p><br /><br /></div><br /><br /><p class=MsoNormal><o:p> </o:p></p><br /><br /><p class=MsoNormal style='margin-bottom:12.0pt'>A new message was posted by<br />Jules Pajot in <br><br /><br><br /><b>Developers</b> --<br><br />  Flex SDK 3.2 : Unmarshalling issue : SOAP objects are not<br />deserialized completely<br><br /><br><br />Nobody has an idea about my problem ? <o:p></o:p></p><br /><br /><div class=MsoNormal><br /><br /><hr size=2 width=200 style='width:150.0pt' align=left><br /><br /></div><br /><br /><p class=MsoNormal style='margin-bottom:12.0pt'>View/reply at <a<br />href="http://www.adobeforums.com/webx?13@@.59b74f93/0">Flex SDK 3.2 :<br />Unmarshalling issue : SOAP objects are not deserialized completely</a><br><br />Replies by email are OK.<br><br />Use the <a<br />href="http://www.adobeforums.com/webx?280@@.59b74f93!folder=.3c060fa3">unsubscribe</a>< br />form to cancel your email subscription.<o:p></o:p></p><br /><br /></div>

  • Catalog objects are not found sometimes.

    Sometimes we hit an error that our catalog objects are not found. We find that the relevant column views in the schema _SYS_BIC are missing. So it should be the root cause. But we don't know why these views are removed.  Could you give us some explanation?
    Thanks,
    Li

    Hi Li,
    I think maybe they are deleted by someone manually.
    BR,
    Phoebe

  • Error - Some objects are not available to your user profile...

    Hello,
    It is for BI 4.1 on Windows. We have a connection called CON1 pointing to DB1. It uses UNIV1 All reports were working fine and we were able to refresh it as well.
    Now the CON1 is changed to point to DB2 and we are now getting following error - "Some objects are not available to your user profile. You cannot refresh this Query. See your Business Objects administrator to request rights".
    If I create a new report using CON1 and the it works fine. Only the old reports are still causing issue on refresh. I tried with Admin account as well and same issue.
    The CON1 is still CON1 and universe UNIV1 is still using CON1. Just the content was edited from DB1 to DB2 in CON1. If we create a new report then no issue.
    Can anybody advice if something needs to compiled. Your help will be greatly appreciated.
    Regards,
    SS

    Your old reports are still pointing to same connection. Remember the DSN has been pointed to use another Database. The records and entries will be different. In addition as the records or object mapping have changed for these reports. Hence this would be a very normal behaviour.
    Create a new connection named CON2 or something like that to point DB1 as per your requirement. This way your original reports would work.

  • Images are not rendered on the PIE03 Client

    Hi Team,
    I have a specific scenario where the Web Dynpro JAVA applications are deployed on Symbol Handheld devices (9090). The applications run fine on majority of the devices, but we have two handhelds where the PIE version 03 client is installed (we are passing the sap-wd-client=Pie03Client parameter). On these devices, the standard images pertaining to the table control UI like the paginator etc are not rendered. We are getting an "X" on the placeholder instead. Has someone faced this problem?
    Can you please provide some pointers? I have no clue as to what is missing here. Any help would be appreciated please.
    Thank you

    Hi Oliver,
    This is the online Mobile solution called "Mobile Webdynpro Online", it supports three clients.
    1. Pie03Client - for Windows Mobile devices.
    2. NokiaS80Client - for Nokia devices
    3. WMLClient - for Blackberry devices
    @Sanjay: can you check on your network speed?
    Best Regards,
    Karthik

  • Transitions are not rendering.  Help?

    I have used iMovie many times, but for some reason my transitions are not rendering now. I place them in and they do not render. I am also having a hard time gettin transition in because after I do one then it shows up as an error and asks me to close the program.
    Any ideas?

    I had a similar thing recently.
    For me the issue was that I'd put text on the clip it was transitioning too - as it can't render both the transition and the text it ignores the transition (it shows it's doing this by greying it out in the project browser).
    To get round it just drag the text a couple of seconds into the clip - essentially remove the overlap.

Maybe you are looking for

  • Create a structure type at runtime

    Hi friends, is it possible to create a local structure type dynamically(at run time).My situation is as follows : The user gives a period of time - for Example from "05.03.2009" to "04.03.2010" Depending on the number of months between the period of

  • No-determination of Contract account in sales order

    Hi All, I have created a Business Partner and created a contract account for the same, but while creating sales order for the same BP, system is asking for contract account, and not allowing me to enter the same in line item, giving an error message

  • Need help installing 8800GT into Mac Pro (early 2008)

    i'm having the hardest time installing my newly purchased (through newegg) evga geforce 8800GT video card into my mac pro (8-core model purchased in early 2008.) when i first installed it and booted up, i heard a nonstop beeeeeeeeep. i called evga an

  • Time machine backup not working right!

    I am running Snow Leopard on a reasonably new imac 20". I have been having problems getting my computer to backup to our timecapule. We have it programmed to automatically backup, but it is coming up with the error message: the backup was not perform

  • Macbook Pro's temperatures.

    I have a 13inch Macbook Pro with an i5 processor and 8gb of ram. Whenever I play minecraft or Rome Total War, my laptop reaches 190 degrees and my fans are at full speed. It also gets really hot. Is this ok? Should I be worried?