Update to graphics only working when maximise window

Hi folks, I'm trying to put together a java application but have run into trouble with a JPanel that displays graphics.
The JPanel is inside of a JScrollPane, which is itself inside of a larger panel in the main JFrame. The JPanel inside of the scrollPane displays some graphics depending upon what is stored in an arraylist that it keeps. What I would like is for the image to be updated when the user adds or changes one of the elements in this arraylist (the user does this by pressing buttons).
Presently, I have it so that when for example the user adds to the arraylist, the repaint() method is called after this addition. However, the image is not changed unless the JFrame itself is maximised (then it appears as I want it). Obviously I would rather it updated without this! :-)
I have experimented with the various paint, repaint, and validating methods to no avail, but I'm hoping this is a problem that has cropped up with people before.
Any help will be greatly appreciated

Sure can. The inner most panel is a chart that increases in size when you add to it. Each row of the chart has a description and a bar (kinda like a gantt chart).
taskList is the arraylist.
getBarLocation is a method that returns the x-position of the bar depending on the date of the task
     public void paint(Graphics g)
          // increase height of the chart to accomodate new tasks
          setPreferredSize(new Dimension(4000, 42 + (taskList.size() * 20) ) );
          Graphics2D g2d = (Graphics2D) g;
          g2d.setFont(new Font("Courier", Font.PLAIN, 12));
          drawMonthsString(g2d);
          g2d.drawString(makeDatesString(), 200, 40);
          g2d.drawLine(0, 41, 4000, 41);
          // now we draw the tasks in
          // this variable tracks progress down y-axis (top pixel of the task)
          int y = 42;
          // this iterates over the list of tasks
          Iterator taskIterator = taskList.iterator();
          while(taskIterator.hasNext())
               Task currTask = (Task) taskIterator.next();
               // write task name
               g2d.drawString(currTask.getName(), 20, y+14);
               // draw bar showing task time
               int barStartX = getBarLocation(currTask.getStartDate());
               int barEndX   = getBarLocation(currTask.getEndDate()) + 12; //to cover last date
               g2d.draw(new Rectangle(barStartX, y, (barEndX-barStartX), 19));
               y += 20;
     Hope that helps your understanding.

Similar Messages

  • My macbook wont start the screen turn blue and stay like that for hrs. It only work when i use safe mode, i try to use disk utilities to fix it but the disk utilities keep saying error and a bunch of other stuff. I dont the cds the comp came with, help.

    my macbook wont start the screen turn blue and stay like that for hrs. It only work when i use safe mode, i try to use disk utilities to fix it but the disk utilities keep saying error and a bunch of other stuff. I dont the cds the comp came with, help. i've tried the command s command p command v but nothing i've tried to the safe mode then a quick restart but nothing
    disk utility give me this:
    Process:         Disk Utility [371]
    Path:            /Applications/Utilities/Disk Utility.app/Contents/MacOS/Disk Utility
    Identifier:      com.apple.DiskUtility
    Version:         11.5.2 (298.4)
    Build Info:      DiskUtility-2980400~60
    Code Type:       X86-64 (Native)
    Parent Process:  launchd [86]
    Date/Time:       2013-11-05 03:29:41.247 -0500
    OS Version:      Mac OS X 10.6.8 (10K549)
    Report Version:  6
    Interval Since Last Report:          9522 sec
    Crashes Since Last Report:           29
    Per-App Interval Since Last Report:  981 sec
    Per-App Crashes Since Last Report:   25
    Anonymous UUID:                      F6B8E263-76C8-4C7D-AA58-48134BF4BA78
    Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000020
    Crashed Thread:  0  Dispatch queue: com.apple.main-thread
    Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
    0   libobjc.A.dylib                         0x0000000100c62fbc _read_images + 312
    1   libobjc.A.dylib                         0x0000000100c79721 map_images_nolock + 1266
    2   libobjc.A.dylib                         0x0000000100c62761 map_images + 115
    3   dyld                                    0x00007fff5fc039c5 dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) + 853
    4   dyld                                    0x00007fff5fc0c849 ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, ImageLoader::RPathChain const&) + 201
    5   dyld                                    0x00007fff5fc04d54 dyld::link(ImageLoader*, bool, ImageLoader::RPathChain const&) + 118
    6   dyld                                    0x00007fff5fc08f7c dlopen + 490
    7   libSystem.B.dylib                       0x0000000100a14e40 dlopen + 61
    8   com.apple.CoreFoundation                0x0000000100d78ef7 _CFBundleDlfcnLoadBundle + 231
    9   com.apple.CoreFoundation                0x0000000100d77e97 _CFBundleLoadExecutableAndReturnError + 1191
    10  com.apple.Foundation                    0x0000000101008355 _NSBundleLoadCode + 638
    11  com.apple.Foundation                    0x0000000101007c78 -[NSBundle loadAndReturnError:] + 742
    12  com.apple.Foundation                    0x000000010101960c -[NSBundle principalClass] + 38
    13  com.apple.framework.DUSupport           0x0000000100082080 -[DUModuleManager(_private) findDUModules:] + 405
    14  com.apple.framework.DUSupport           0x0000000100081ed9 -[DUModuleManager orderedModuleListOfModules] + 40
    15  com.apple.DiskUtility                   0x0000000100006082 0x100000000 + 24706
    16  com.apple.DiskUtility                   0x0000000100005f59 0x100000000 + 24409
    17  com.apple.AppKit                        0x0000000101444625 -[NSWindowController _windowDidLoad] + 538
    18  com.apple.AppKit                        0x00000001013e1f77 -[NSWindowController window] + 112
    19  com.apple.AppKit                        0x00000001015f61d9 -[NSWindowController showWindow:] + 47
    20  com.apple.AppKit                        0x00000001015c7c5c -[NSDocument showWindows] + 98
    21  com.apple.AppKit                        0x00000001015c64bb -[NSDocumentController openUntitledDocumentAndDisplay:error:] + 340
    22  com.apple.AppKit                        0x00000001014f7b44 -[NSDocumentController(NSInternal) _openUntitled] + 111
    23  com.apple.AppKit                        0x00000001014f79ab -[NSApplication _doOpenUntitled] + 257
    24  com.apple.AppKit                        0x00000001014f733b -[NSApplication(NSAppleEventHandling) _handleAEOpen:] + 185
    25  com.apple.AppKit                        0x00000001014f6fd9 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 77
    26  com.apple.Foundation                    0x0000000100ffd0d6 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 360
    27  com.apple.Foundation                    0x0000000100ffcf06 _NSAppleEventManagerGenericHandler + 114
    28  com.apple.AE                            0x0000000104d7332b aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 162
    29  com.apple.AE                            0x0000000104d73224 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 32
    30  com.apple.AE                            0x0000000104d7312b aeProcessAppleEvent + 210
    31  com.apple.HIToolbox                     0x00000001028a0619 AEProcessAppleEvent + 48
    32  com.apple.AppKit                        0x00000001013fc095 _DPSNextEvent + 1191
    33  com.apple.AppKit                        0x00000001013fb801 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 155
    34  com.apple.AppKit                        0x00000001013c168f -[NSApplication run] + 395
    35  com.apple.AppKit                        0x00000001013ba3b0 NSApplicationMain + 364
    36  com.apple.DiskUtility                   0x0000000100002009 0x100000000 + 8201
    37  com.apple.DiskUtility                   0x0000000100001db8 0x100000000 + 7608
    Thread 1:  Dispatch queue: com.apple.libdispatch-manager
    0   libSystem.B.dylib                       0x0000000100a27c0a kevent + 10
    1   libSystem.B.dylib                       0x0000000100a29add _dispatch_mgr_invoke + 154
    2   libSystem.B.dylib                       0x0000000100a297b4 _dispatch_queue_invoke + 185
    3   libSystem.B.dylib                       0x0000000100a292de _dispatch_worker_thread2 + 252
    4   libSystem.B.dylib                       0x0000000100a28c08 _pthread_wqthread + 353
    5   libSystem.B.dylib                       0x0000000100a28aa5 start_wqthread + 13
    AND MORE TOO MUCH TO COPY N PASTE HELP PLEASE!!!!!

    Reset the PRAM
    Reinstall the operating system from the dvd (you will not loose your data)

  • Airdrop only works with Airdop window open

    I have Airdop running on two computers. But it only works when both computers have the Airdop window open. That is stupid. When somebody wants to send you something he can't see your computer when the Airdop window is closed. If Apple means this as a "do not disturb function" it would be done better with a switch. I don't like to have windows open.
    Steffen

    Sorry, but I have to agree with the OP. There should be a switch, and perhaps the default for that switch should be as you stated, however it would be great to have the option there.
    And anyway, with file sharing on (like most Macs on my uni network have, see attached), you can put anything in their drop boxes at any time. Airdrop is a simplified version of this, so why not have an always on option as well?
    Waiting for a clever person to come up with hack. Perhaps it drains battery life in terms of the ad hoc feature of Airdrop. I dunno.

  • Why my Firefox only works when I move my mouse?

    I just updated my firefox and it only works when I move my mouse

    Hello jordypaige11,
    The following article provdies some useful tips and troubleshooting that can help stabilize your iPhone's cellular data connection.
    iPhone: Troubleshooting a cellular data connection
    http://support.apple.com/kb/TS3780
    Cheers,
    Allen

  • Ipw3945 only working when modprobing manually / not on startup

    The last kernel update broke my wireless.
    When booting, the ipw3945d daemon will tell me "ERROR: Could not find Intel PRO/Wireless 3945ABG Network Connection". After it finishes booting, I can rmmod the ipw3945 module and modprobe it again. Starting the daemon after that works flawlessly. Even if I try to start the daemon manually after the booting sequence, I'll get that error. I first need to rmod and modprobe ipw3945 for it to work. So...:
    [21:32:40 | shapeshifter@Tachycineta ~]$ sudo /etc/rc.d/ipw3945d start
    :: Starting IPW3945d                                                                                                [BUSY]
    2008-03-01 21:32:47: ERROR: Could not find Intel PRO/Wireless 3945ABG Network Connection
                                                                                                                                  [DONE]
    [21:32:48 | shapeshifter@Tachycineta ~]$ sudo rmmod ipw3945
    [21:32:50 | shapeshifter@Tachycineta ~]$ sudo modprobe ipw3945
    [21:32:53 | shapeshifter@Tachycineta ~]$ sudo /etc/rc.d/ipw3945d start
    :: Starting IPW3945d                                                                                                [DONE]
    [21:32:57 | shapeshifter@Tachycineta ~]$
    And I have no idea why it only works when modprobing manually.
    Anyone?
    Last edited by TB2 (2008-03-01 23:05:33)

    zenlord wrote:
    Are you sure it's driver-related? I have never heard anyone complain about deassociating wireless networks unless they were using networkmanager or wicd or something like that. In the various threads about netcfg2 I have never seen anyone with this problem.
    Zl.
    I don't know if it's driver-related, but it could be power-related: iwl3945 isn't able to retrieve my ap essid everytime, since on the other hand ipw3945 is able to do, with the laptop in the SAME position.
    Last edited by uastasi (2008-03-13 20:10:18)

  • My ipod only works when its being charged!

    my ipod only works when its charged. when i unplug it the screen slowly fades out and i can no longer turn it on. and when i connect it to the computer it doesnt even connect! can someone please help me???!!!!
    ipod video   Windows XP  

    "my ipod only works when its charged."
    Then it sounds like a battery problem.
    Try these.
    My iPod won't turn on.
    iPod has no power and appears frozen.
    iPod battery doesn't charge.
    If none of the above help, then it may be an issue that requires service.
    You can arrange online service here.
    Service request.
    Or if an Apple store is near you, take it there and have them check your iPod.

  • 7th gen Nano only works when plugged in, turns off when  unplugged... battery is fully charged.

    7th gen Nano only works when plugged into computer, as soon as I unplug it shuts off (it was ejected from iTunes). Battery is fully charged.  Have already done a restore in iTunes and checked for updated software. 

    Hello there, DizDude.
    The following Knowledge Base article offers up some good recommendations for troubleshooting battery issues with the 7th generation iPod Nano:
    iPod nano (7th generation): Hardware troubleshooting
    http://support.apple.com/kb/TS4433
    Particularly this section:
    Battery life appears short
    Learn how to conserve battery life.
    Ensure that the latest software is installed on the iPod.
    When charging, use the cable that came with iPod nano (7th generation) and leave the device connected until it is fully charged.
    Note: If you are charging using your computer, don't connect iPod nano (7th generation) to your keyboard. Also, the computer must be turned on and not in sleep or standby mode. If iPod nano (7th generation) is connected to a computer that's not turned on or is in sleep or standby mode, the iPod nano (7th generation) battery may drain.
    When you are done using the iPod nano, verify that:
    The Radio application is off (tap the button)
    Music is paused (tap the button in the iPod application or disconnect the earphones)
    There is no active Pedometer session (tap the Stop button in the Fitness application)
    Dimming the screen is another way to extend battery life on iPod nano. Go to Settings > General > Brightness and restore the brightness to the default, or drag the slider to the left to lower the default screen brightness.
    Playing tracks with EQ requires your iPod processor to consume more energy than playing tracks without EQ, because the EQ information is not encoded in the song. To prolong battery life, turn EQ off if you don't use it. Go to Settings > Music > EQ and select Off from the list. Note, however, that if you've added EQ to tracks in iTunes, you'll need to set EQ to Flat to have the effect of Off, because iPod keeps your iTunes settings intact.
    Try restoring iPod nano (7th generation) by connecting it to iTunes and clicking Restore.
    Test the battery life.
    Issue not resolved
    If the issue is still not resolved, please read this information on servicing your iPod.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • Iphone 4: Home Button Not Working. The home button only works when it is connected to iTunes, once i disconnet it does not work, i have tried a restore to factory settings but it still is not working. Any suggestions?

    iphone 4: Home Button Not Working. The home button only works when it is connected to iTunes, once i disconnet it does not work, i have tried a restore to factory settings but it still is not working. Any suggestions?

    Apple, as I said, does not repair your iPhone. All hardware service issues are handled by replacing the unit. So they can't handle the home-button issue without also addressing the issue of the cracked screen, for which they'll almost certainly charge you. But you can make an appointment at an Apple Store or call Apple tech support and plead your case.
    Regards.

  • My Airport Time Capsule only works when I turn off and turn on, but I think this may end up with the unit. What can this happening and how to solve?

    Time Capsule Airport
    Hello to all, good day, sorry my english google, but it is the tool I have at the moment. I'm having trouble with my Time Capsule Airport, I made all the settings according to the manual, but there has been a connection problem with my iMac. When I finish my work I turn off the imac and then again when they return to work and care, it can not connect to Time Capsule Airport, making it impossible to remove the files and make back up by Time Machine only works when I turn off and turn on the Airport Time Capsule , but I think this may end up with the unit. What can this happening and how to solve? Thank you.
    Olá a todos, bom dia, desculpe meu inglês google, mas é a ferramenta que tenho no momento. Estou tendo dificuldades com a minha Airport Time Capsule, fiz todas as configurações de acordo com o manual, mas tem existido um problema de conexão com meu iMac. Quando termino meus trabalhos desligo o imac e depois quando retorno pra trabalhar novamente e ligo, ele não se conecta a Airport Time Capsule, impossibilitando retirar os arquivos e fazer o back-up pelo Time Machine, só funciona quando desligo e ligo a Airport Time Capsule, mas acho que isso pode acabar com o aparelho. O que pode esta acontecendo e como resolver? Obrigado.

    This is easier to do with pictures perhaps.. since we do not share a common language and machine translation leaves a lot to be desired.
    In the airport utility bring up your Time Capsule.
    Simply post the screenshots here.
    So here is mine.
    Click on the Edit button and give us the Internet and Wireless and Network tab..
    eg.
    Please also make sure you are set to ipv6 in your wireless or ethernet .. whichever is used.. and do tell which.
    This is wifi in your computer.
    The following are important..
    DO not use long names with spaces and non-alphanumeric names.
    Use short names, no spaces and pure alphanumeric.
    eg TC name. TCgen5
    Wireless name TCwifi
    Use WPA2 Personal security with 10-20 character pure alphanumeric password.
    read apple instructions to help with TM and TC.. they did finally admit it has issues in Mavericks.
    OS X Mavericks: Time Machine problems
    Mount the TC manually in finder.
    AFP://TCgen5.local
    When asked for the password .. that is the disk access password and save it in the keychain.
    Reset Time Machine
    See A4 here. http://pondini.org/TM/Troubleshooting.html

  • My Ipod touch will only work when plugged into a itouch radio.  When I take it out, it goes blank.  Why can I do?

    My Ipod touch will only work when plugged into an Itouch radio.  When I take it out of the charger, it goes blank.  The battery shows fully charged.  It appears that the battery is no longer charging.  What should I do?

    Try a reset: Hold the home and power buttons at the same time until the Apple boot logo appears. No data will be lost. If that fails, the battery may have gone kaput.

  • My ipod nano 4th generation only works when it is plugged into the computer; otherwise, the screen turns black and it is completely unresponsive to any efforts such as pushing buttons, reseting, etc. What should I do?

    My ipod nano 4th generation only works when it is plugged into the computer; otherwise, the screen turns black and it is completely unresponsive to any efforts such as pushing buttons, reseting, etc. What should I do?

    Sounds like the battery is shot and in need of a replacement.  You can have Apple replace the battery for a flat fee or you can send it into a third party repair center for a bit less.
    Not much else you can do for troubleshooting this one.
    B-rock

  • I recently repaired disk permissions on my mac HD and now my on-board speakers wont work, the icon is greyed out and only works when my headphones are plugged in.

    I recently repaired disk permissions on my mac HD and now my on-board speakers wont work, the icon is greyed out and only works when my headphones are plugged in

    Try to put your headphones several times in and out from your connection, might be the switch is stuck. Normally it should work again while trying to plug the headphones in and out!

  • My CD/DVD Drive Only Works When I Jam the CD/DVD in hard..?

    My CD/DVD drive only works when I stuff the CD/DVD in the drive EXTRA hard. If I just try to put in with normal force (that at one time worked) it spins the disc around, makes a spinning noise, and then ejects it. I'm taking it to the Apple Store soon. What should I expect to be wrong and is it fixable? Please share details. Thanks in advance.

    Welcome to Apple Discussions!
    It sounds like the spring that loads the drive has gotten jammed by something. This can often happen if you use CDs with sticky labels, or do anything to label the discs directly. As a result of issues like these, I've not labeled any discs directly, and instead store the in jewelcases, and purchase them prepackaged in jewelcases to avoid such issues.

  • Upgrading to Mavericks wrecked my MacBook Pro & now it only works when external hard drive is plugged in

    So I tried to upgrade to Mavericks today and it failed (same error as in this post which seemed to be a common problem). It wouldn't let me repair the disk, and after trying all sorts I rebooted my computer in recovery mode - it wouldn't let me reinstall Lion because the hard drive was apparently locked and I could see no way around this. So I decided to restore from a Time Machine backup on an external hard drive and that worked okay, except my MacBook now only works when the external hard drive is connected. If I remove the external hard drive, I'm back to square one as it still won't let me reinstall Lion as the HD is locked!
    I have no idea what's going on. HELP!

    The startup drive is failing, or there is some other internal hardware fault.
    Make a "Genius" appointment at an Apple Store, or go to another authorized service provider.
    If privacy is a concern, erase the data partition(s) with the option to write zeros* (do this only if you have at least two complete, independent backups, and you know how to restore to an empty drive from any of them.) Don’t erase the recovery partition, if present.
    Keeping your confidential data secure during hardware repair
    Apple also recommends that you deauthorize a device in the iTunes Store before having it serviced.
    *An SSD doesn't need to be zeroed.

  • What's wrong with my MacBook, it only works when its plugged in to the wall charger

    my MacBook only works when its plugged in with the wall charger. What's wrong with it? it the problem fixable ?

    Marina -
    What Kappy said, or maybe your Battery charging cable is faulty, or something's happened to the input slot.
    I'd take it to Apple and have them troubleshoot it for you. 

Maybe you are looking for

  • Oracle BPM 12c: getting error while opening of bpm project in bpm composer

    Hi, I am importing bpm project into bpm composer from jdeveloper using PAM and export/import utility but I am not able to open it into the bpm composer. I am getting following error: javax.faces.el.EvaluationException: java.lang.NullPointerException

  • Installing Flash Player w/Safari  error message

    Attempting to install Flash Player and error message - Close Safari and safari is closed. Any ideas on how to trouble shoot?

  • Encoding on terminal to read/write ntfs hard drive help!

    I encoded in Terminal the codes that were posted online regarding the enabling of read/write for ntfs hard drive but something went wrong during the process. Would it be possible to undo it? Would there be any code to disable it so I could at least r

  • Backround for Matrix-cell

    Hello, I have a question concerning the System Matrix 38. Is it possible to set a backround color of a particular cell of an UDF? Thank you in advanced for your time. Best Regards Vural

  • Aperture applying unwanted adjustments when loading an image

    Hello, I'm having a bit of an issue with Aperture and I'm wondering if the community can help me. My camera is a Canon Eos 600D. I'm running Aperture 3.4.3 on a Mid 2010 iMac 27", with 8GB of Ram. Just lately, when I import and load images into Apert