Keeping Swing calls on the EDT, app code off the EDT, and boilerplate code

I have been reading about the EDT and Swing for a while now and I have not been able to find very good tutorials or explanations. I understand that swing calls should be on the EDT and I have seen hints about application code needing to be on its own thread, which seems obvious. I have seen code for how to do this, but it seems like in order to really enforce these rules, I'd have to setup invoke SwingUtilities.invokeLater on all my swing related functions (I have a ton of them), and then for non-swing related functions, I'd have to constantly check to make sure they are not on the EDT with javax.swing.SwingUtilities.isEventDispatchThread?

BoBear2681 wrote:
Also keep in mind that many very quick non-UI tasks can safely be done on the EDT. For example, if you load a very small text file (a few KB), this is usually so fast that there's no need to do it off the EDT. Just pointing out that not literally everything needs to be done off the EDT, just anything that runs long enough to produce a noticeable unresponsive pause in your GUI. Users are okay with an application taking 0.1 seconds to open a file, for example. But doing 10 seconds of number crunching, connecting to a remote server, etc. are the kinds of things you'd want to do off the EDT.That's extremely true, and I meant to touch on that but forgot (yep, my memory is so bad that I forget what I was going to type in the amount of time it takes to post a reply).
When I first started to figure out the EDT, I became paranoid about keeping non-GUI stuff off of it. However, I've since realized that sometimes it's unavoidable, and usually it doesn't matter anyway.

Similar Messages

  • My phone keeps dropping calls.  The phone reads call failed!

    my phone keeps dropping calls.  The phone reads call failed!  (as this is how I find out where I am working each day.  I am losing money Help!)

    Settings > General > Reset > Reset Network Settings
    If the issue persists, contact the carrier.

  • I have a problem mackeeper keep opening up another tab and these little green circle stuff keep popping up on the page and overtime my cursor hover over it it pops up a little box with stuff in it does anyone have an idea how to get rid of it?

    i have a problem mackeeper keep opening up another tab and these little green circle stuff keep popping up on the page and overtime my cursor hover over it it pops up a little box with stuff in it does anyone have an idea how to get rid of it?

    You installed a variant of the "VSearch" trojan. Remove it as follows.
    This malware has many variants. Anyone else finding this comment should not expect it to be applicable.
    Back up all data before proceeding.
    Triple-click anywhere in the line below on this page to select it:
    /Library/LaunchAgents/com.2c232f1e4d12129e.agent.plist
    Right-click or control-click the line and select
              Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item selected. Drag the selected item to the Trash. You may be prompted for your administrator login password.
    Repeat with each of these lines:
    /Library/LaunchDaemons/com.2c232f1e4d12129e.daemon.plist
    /Library/LaunchDaemons/com.2c232f1e4d12129e.helper.plist
    Restart the computer and empty the Trash. Then delete the following items in the same way:
    /Library/Application Support/2c232f1e4d12129e
    /System/Library/Frameworks/v.framework
    The trouble may have started when you downloaded and ran an application called "MPlayerX." That's the name of a legitimate free movie player, but the name is also used fraudulently to distribute VSearch. If there is an item with that name in the Applications folder, delete it, and if you wish, replace it with the genuine article from mplayerx.org.
    This trojan is often found on illegal websites that traffic in pirated content such as movies. If you, or anyone else who uses the computer, visit such sites and follow prompts to install software, you can expect more of the same, and worse, to follow. Never install any software that you downloaded from a bittorrent, or that was downloaded by someone else from an unknown source.
    In the Security & Privacy pane of System Preferences, select the General tab. The radio button marked Anywhere  should not be selected. If it is, click the lock icon to unlock the settings, then select one of the other buttons. After that, don't ignore a warning that you are about to run or install an application from an unknown developer.
    Then, still in System Preferences, open the App Store or Software Update pane and check the box marked
              Install system data files and security updates (OS X 10.10 or later)
    or
              Download updates automatically (OS X 10.9 or earlier)
    if it's not already checked.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • I'm unable to change my security question answers.  It keeps asking me for the answers and I don't know them!

    I'm unable to change my security question answers.  It keeps asking me for the answers and I don't know the answers.  I've reset my password 2x and it still won't let me change the answers.  Help!!

    See Kappy's great User Tips.
    See my User Tip for some help: Some Solutions for Resetting Forgotten Security Questions: Apple Support Communities https://discussions.apple.com/docs/DOC-4551
    Send Apple an email request for help at: Apple - Support - iTunes Store - Contact Us http://www.apple.com/emea/support/itunes/contact.html
    Call Apple Support in your country: Customer Service: Contacting Apple for support and service http://support.apple.com/kb/HE57
     Cheers, Tom

  • HT3606 i keep trying to update the software and it gets stuck on configuration, so i can i sped up the process?

    i keep trying to update the software and it gets stuck on configuration, so i can i sped up the process?

    Some general advice on updating:
    It is worth noting that it is an extreme rarity for updates to cause upsets to your system, as they have all been extensively beta-tested, but they may well reveal pre-existing ones, particularly those of which you may have been unaware. If you are actually aware of any glitches, make sure they are fixed before proceeding further.
    So before you do anything else:
    If you can, make a full backup first to an external hard disk. Ideally you should always have a bootable clone of your system that enables you to revert to the previous pre-update state.
    Turn off sleep mode for both screen and hard disk.
    Disconnect all peripherals except your keyboard and mouse.
    1. Repair Permissions (in Disk Utility)
    2. Verify the state of your hard disk using Disk Utility. If any faults are reported, restart from your install disk (holding down the C key), go to Disk Utility, and repair your startup disk. Restart again to get back to your startup disk.
    At least you can now be reasonably certain that your system does not contain any obvious faults that might cause an update/upgrade to fail.
    3. Download the correct version of the COMBO update from the Apple download site.
    The Combo updater of Leopard 10.5.8 can be found here:
    http://support.apple.com/downloads/Mac_OS_X_10_5_8_Combo_Update
    If you prefer to download updates via Software Update in the Apple menu (which would ensure that the correct version for your Mac was being downloaded), it is not recommended to allow SU to install major (or even minor) updates automatically. Set Software Update to just download the updater without immediately installing it. There is always the possibility that the combined download and install (which can be a lengthy process) might be interrupted by a power outage or your cat walking across the keyboard, and an interrupted install will almost certainly cause havoc. Once it is downloaded, you can install at a time that suits you. You should make a backup copy of the updater on a CD in case you ever need a reinstall.
    Full details about the 10.5.8 update here: http://support.apple.com/kb/HT3606
    More information on using Software Updater here:
    http://support.apple.com/kb/TA24901?viewlocale=en_US
    Using the Combo updater ensures that all system files changed since the original 10.5.0 are included, and any that may have been missed out or subsequently damaged will be repaired. The Delta updater, although a temptingly smaller download, only takes you from the previous version to the new one, i.e. for example from 10.5.7 to 10.5.8. Software Update will generally download the Delta updater only. The preferable Combo updater needs to be downloaded from Apple's download site.
    Now proceed as follows:
    4. Close all applications and turn off energy saving and screensaver.
    5. Unplug all peripherals except your keyboard and mouse.
    6. Install the update/upgrade. Do not under any circumstances interrupt this procedure. Do not do anything else on your computer while it is installing. Be patient.
    7. When it ask for a restart to complete the installation, click restart. This can take longer than normal, there are probably thousands of files to overwrite and place in the correct location. Do nothing while this is going on.
    8. Once your Mac is awake, repair permissions again, and you should be good to go!
    If your Mac seems slightly sluggish or ‘different’, perform a second restart. It can’t hurt and is sometimes efficacious! In fact a second restart can be recommended.
    9. Open a few of your most used applications and check that all is OK. In this connection please remember that not all manufacturers of third party applications and plug-ins, add-ons, haxies etc, will have had time to do any necessary rewrites to their software to make them compliant with the latest version of your operating system. Give them a week or two while you regularly check their websites for updates.
    N.B. Do not attempt to install two different updates at the same time as each may have different routines and requirements. Follow the above recommendations for each update in turn.
    Lastly, Apple's own article on the subject of Software Update may also be useful reading:
    http://docs.info.apple.com/article.html?artnum=106695
    [b]If you are updating Safari (or just have):[/b]
    Input Managers from third parties can do as much harm as good. They use a security loophole to reach right into your applications' code and change that code as the application starts up.  If you have installed an OS update and Safari is crashing, the very [i]first[/i] thing to do is clear out your InputManagers folders (both in your own Library and in the top-level /Library), log out and log back in, and try again.
    So, disable all third party add-ons before updating Safari, as they may not have been updated yet for the new version. Add them back one by one. If something goes awry, remove it again and check on the software manufacturer's website for news of an update to match your version of Safari.
    Most errors reported here after an update are due to an unrepaired or undetected inherent fault in the system, and/or a third party add-on.
    Additional tips on software installation here:
    http://docs.info.apple.com/article.html?artnum=106692
    To reiterate, Input Managers reach right into an application and alter its code. This puts the behavior of the affected application outside the control and responsibility of its developers: a recipe for  problems. That's not to say that issues absolutely will ensue as a result of Input Managers, but you, as a user, must decide. If the functionality of a specific Input Manager or set thereof is really important to you, you may well choose to assume the associated risk.
    Again, the advice is to remove all Input Managers from the following directories:
    /Library/InputManagers
    ~/Library/InputManagers
    especially prior to system updates (they can always be added back one-by-one later).
    Solutions for troubleshooting installation, startup, and login issues in Mac OS X v10.5
    http://support.apple.com/kb/TS1541?viewlocale=en_US

  • My ipod touch was interrupted during an update and now my itunes cant recognise the device, and ive tried to restore it but it just keeps coming up with the usb and itunes picture. how do i fix this? Please help

    my ipod touch was interrupted during an update and now my itunes cant recognise the device, and ive tried to restore it but it just keeps coming up with the usb and itunes picture. how do i fix this? Please help

    http://support.apple.com/kb/HT1808

  • My mouse keeps jumping all over the place and i dont know why!

    My trackpad doesnt allow me to fully control the mouse on the screen! it keeps jumping all over the place and i dont knw why! i updated my computer yesterday and it was working fine but by the end of the night it started to not function properly again.                   

    A fairly well known flaw that occurs to some trackpads. See here: http://support.apple.com/kb/TS1449

  • I've got an iPad and iPhone 4S, both of which are set up for facetime. When someone calls me, both the iPad and phone ring, even though the phone is set to receive facetime calls on the number and the iPad is set for an email account. why is this?

    I've got an iPad and iPhone 4S, both of which are set up for facetime. When someone calls me, both the iPad and phone ring, even though the phone is set to receive facetime calls on the number and the iPad is set for an email account.
    How can I change the setup so on the email only the iPad rings and on the phone number only the phone rings?

    No it's not stealing. They have an allowance that you can share with so many computers/devices. You'll have to authorize her computer to play/use anything bought on your acct. You can do this under the Store menu at top when iTunes is open on her computer.
    As far as getting it all on her computer....I think but I am not sure (because I don't use the feature) but I think if you turn on Home Sharing in iTunes it may copy the music to her computer. I don't know maybe it just streams it. If nothing else you can sign into your acct on her computer and download it all to her computer from the cloud. Not sure exactly how to go about that, I haven't had to do that yet. I wonder if once you authorize her computer and then set it up for automatic downloads (under Edit>Preferences>Store) if everything would download. Sorry I'm not much help on that.

  • My macbook air has gotten slow this past week i have changed browsers and the beach ball keeps coming up all the time and on a game i play it says the network is slow can anyone help me?

    my macbook air has gotten slow this past week i have changed browsers and the beach ball keeps coming up all the time and on a game i play it says the network is slow can anyone help me

    Go step by step and test.
    Restart the router. Restart the computer.
    OS X 10.7 Lion / 10.8. Mountain Lion
    http://support.apple.com/kb/PH3915
    Start up in Safe Mode.
    http://support.apple.com/kb/PH4373
    Repair Disk
    Steps 1 through 7
    http://support.apple.com/kb/PH5836?viewlocale=en_US
    Reset SMC.
    http://support.apple.com/kb/HT3964
    Choose the method for:
    "Resetting SMC on portables with a battery you should not remove on your own".
    Increase Disk Space
    http://support.apple.com/kb/PH10677?viewlocale=en_US
    Best.

  • My screens keep jumping all over the screen and changing size while I am trying to work why?

    My opened pages keep jumping all over the screen and changing sizes while I am trying to work - what is causing this?

    Madafk wrote:
    .... - I really love this Mac but it is taking a bit of getting use to
    Cheers
    You may find these Links helpful in enjoying your Mac...
    http://www.apple.com/support/mac101/
    http://www.apple.com/support/switch101/     Switching from PC
    Find Out How (Video)
    http://www.apple.com/findouthow/mac/

  • Why does Mobile Data notification keep coming up saying 'Mobile Data is turned off for "Numbers" and I have to click on OK to get rid of it? I KNOW it's turned off for that program because that is what I want it to be set at. What I DON'T want is to have

    Why does Mobile Data notification keep coming up saying 'Mobile Data is turned off for "Numbers" and I have to click on OK to get rid of it? I KNOW it's turned off for that program because that is what I want it to be set at. What I DON'T want is to have to click on OK EVERY TIME I open the program when I'm away from wifi.

    That is how it works in general, not just for Numbers. It irritates me on other apps at times, although I can see an argument that if it didn't do that then people would complain about missing functionality after they forgot they had turned data off for an app. At any rate, this is a user to user support forum and we can't do anything about it. If you want to make a suggestion to Apple, following is a place to do that: http://www.apple.com/feedback/

  • I keep getting calls from non existing area codes and phone numbers.  They are never the same number twice.  How do I stop this?

    About a week ago I started getting phone calls on my cell phone from numbers that do not exist, including the area codes.  I can not report these to the Do Not Call list because the area code is non existent.  I'm getting these calls all the time now and never from the same number twice so there's no point in blocking them.  If I answer I may or may not get a person who has an accent from India so heavy that I can't understand what they are saying.  This is getting to the point where I just want to cry I'm so frustrated.  Anyone else having this issue or does anyone know how to stop it?
    Thank you

    I'm sorry that you are having all these troubles. I have sent you a private message.
    Anthony_VZ
    **If someones post has helped you, please acknowledge their assistance by clicking the red thumbs up button to give them Kudos. If you are the original poster and any response gave you your answer, please mark the post that had the answer as the solution**
    Notice: Content posted by Verizon employees is meant to be informational and does not supersede or change the Verizon Forums User Guidelines or Terms or Service, or your Customer Agreement Terms and Conditions or plan

  • Stupid questions about keeping important calls on the FX application thread

    I'm working on a project that I've been developing for about the last 6 months. I'm using JavaFX as the graphical side, but I'm taking input from a music processing program called Max/MSP, and I'm getting user input from a camera. Both of these things need to run on separate threads from my FX application thread. Up until now, things have been going smoothly. I can manipulate things on screen from my user input, and I have two way communication working between my JavaFX application and Max. Now, however, I need to start actually drawing stuff at runtime. Up until now, pretty much all FX side manipulations of been to just make translations. I now need to create, add, and remove children from Nodes. So I'm of course getting an error saying "not on FX application thread". I understand why it isn't on this thread, and why this is a problem. So I made some changes, so that calls that will make changes to the nodes on the stage, will only note the data, and then make the changes later, on the FX application thread. And then I run into problems, involving my own stupidity...
    I have no idea how to get these calls onto the FX application thread. I mean, this should be really easy. I'm obviously missing something. Or maybe I'm just really tired, and have been looking at this for too long, or maybe the fact that it's been 6 months since I wrote this part of the code. But I see my Mainstage class, which extends Application. It has a start function, which sets up all my on screen do-dads (extended from Nodes and such), calls stage.show()... and then seems to end. When I've done things like call translate functions on my nodes from my user input thread, or from my communication from Max thread, things seemed to have worked. But now I'm thinking I might have been handling that wrong from the ground up. It seems likely that I should be having a "main game loop" (it isn't actually a game, but still, same principle) where I can tell the stage to update all the various nodes with the changes that have happened since the last frame, and try to get everything to update in time for the graphics to render at a reliable frame rate. And yet, I'm just not seeing how to do that. I'm sure this should be obvious, but I'm flat out blanking. And the time crunch is starting to descend... Please, if you can point out some standard way of avoiding this hopefully common newb mistake, I would greatly appreciate it!
    -cullam

    Checkout the documentation on "Pulse" in the JavaFX Archictecture overview which may help clarify some of your questions.
    http://docs.oracle.com/javafx/2.0/architecture/jfxpub-architecture.htm
    In simple terms, as I understand it, the framework will check 60 times a second if anything is dirty and needs repainting. If everything is clean, it will do nothing. If something is dirty, it will repaint it (although the repaint is kind of clever and highly optimized to support region image caching, make use of hardware rendering, etc).
    So you can see that the main rendering loop is essentially hidden from you. Instead you construct a SceneGraph, the system checks regularly whether or not the SceneGraph has changed, and if it has it renders the updated SceneGraph.
    In most JavaFX applications, you have a UI with controls and add event handlers which respond to control input to update the SceneGraph. In such programs, creating a main loop is unnecessary.
    You can set up an animation timeline say at, for example, 30fps (half the pulse rate), then, on every other pulse, nothing will have changed so no redraw will happen. This is only necessary if you are performing an animation or capturing camera input, etc yourself (rather than using a Transition for example).
    Actually, if I get my state changes working properly in a runLater call, do I need to also write a main loop? No, you don't need to write a main loop. Depending on the exact application, you may want one, but if you are already getting events generated by your camera input at 30fps, processing each 30fps from the camera in a runLater call would work fine without creating a loop.
    But you do need to be careful that you don't send too many runLater calls and eventually overload the JavaFX event queue. For example it makes no sense to make more than 60 runLater calls a second to update the scene, because the system will never update the scene more than 60 times a second anyway.
    If you do get a working camera app integrated with JavaFX, please post or blog about it as I am sure many people are interested in such an application.

  • Can you mix calls to the Posix and native thread librariess?

    Is it possible to mix calls to different thread libraries within the same process.
    We have a shared library interface to our product which is called from a customers application. In order to provide a thread safety we need to protect global data in this library with a mutex. However we do not know which thread library (if any) will be used by the calling application.
    If we used a Posix mutex in our library would it work if the calling application was implemented using non-Posix threads?
    Are the Posix and Solaris thead header files different interfaces to the same underlying implementation?
    What overheads are there loading the thread library when it is not needed? If for example the calling application was implemented without using threads.
    Would we have to test our interface with the different thread implementations available? eg /usr/lib/lwp/libthread.so, /usr/lib/sparcv9/libthread.so as well as /usr/lib/libthread.so.

    I know the author of the original post wrote this long ago, but I thought I'd write a reply in case anyone else stumbles on this like I just did.
    Is it possible to mix calls to different thread
    libraries within the same process.Yes. Though you have to be careful about compilation and link flags, and the order of libraries specified on the link command-line (-lpthread and -lthread). For complete information, refer to the Solaris "Multithreaded Programming Guide", available at http://docs.sun.com in the the Solaris 8 (or whatever version) Software Developer Collection.
    If we used a Posix mutex in our library would it work
    if the calling application was implemented using
    non-Posix threads?Yes.
    Are the Posix and Solaris thead header files different
    interfaces to the same underlying implementation?Yes, I believe so. POSIX specifies an interface. I think the Solaris threads implementation was part of the Solaris OS before pthreads were supported on it. Anyway Solaris really uses "LWPs" (Lightweight Processes) at the kernel level, and user-level threads (POSIX or Solaris threads) are mapped onto LWPs.
    What overheads are there loading the thread library
    when it is not needed? If for example the calling
    application was implemented without using threads.You should never link to the thread library when it is not needed. It results in unnecessary overhead. This is documented in the book mentioned above.
    Would we have to test our interface with the different
    thread implementations available? eg
    /usr/lib/lwp/libthread.so,
    /usr/lib/sparcv9/libthread.so as well as
    /usr/lib/libthread.so.I don't think so, but judge for yourself; I suspect if any inconsistent behavior is found it will have more to do with defects in these implementations than in your own code. On Solaris 8:
    - /usr/lib/libthread.so is the default Solaris threads library that does a many-to-many mapping of user-level threads to kernel-level-lwp's
    - /usr/lib/lwp/libthread.so is the "alternate" Solaris threads library that does a 1-to-1 mapping of user-level threads to kernel-level-lwp's
    - /usr/lib/sparcv9/libthread.so I think is the fully 64-bit version of the default libthread
    Hope this helps somebody.

  • My iPod 4th-gen charges just fine in any wall outlet, but when connected to my brand new ASUS Windows-8 laptop's USB 3.0 port the charging process just keeps "blinking" on both the iPod and the laptop and will not connect to Itunes...

    Hi, I HATE to ask for help with this, but I HAVE looked everywhere and Google searched different wordings and have not found anything similar nor a solution to my problem!                                                                                                                                                                                                                               My good old iPod 4th-gen charges just fine in any wall outlet, in any house, but when I connect it to my brand new ASUS laptop that has Windows-8 and 3.0 USB ports using the charging/data cable, the charging process just keeps "blinking" BOTH the iPod and the laptop and it will not connect to ITunes and I get "A Device is Detected" message that keeps popping up and going away over and over right above the Windows desktop toolbar.                                                               When I go to control panel and select "Devices" it does show the iPod, but for only a split second and than it disappears, but than it comes back again for a split second and than it disappears again and just keeps doing that over and over and over!                                                                                                                  I have tried resetting the iPod while it is plugged into the laptop by holding the power and menu buttons, that did no good.                                                             I also tried uninstalling iTunes and any other Apple stuff listed and reinstalling it all, that did NOT work!                                                                                          The iPod, the laptop and iTunes ARE all fully updated!                                                                                                                                                                I AM using a brand new charging/data cable that I just opened up an hour ago (I've learned to keep a few brand new ones around at all times since these piece of garbage rip-off cables hardly last a week, even when you baby them!). I also tried a few old cables, they all do the same thing!                                                       I would like to get this piece of junk to connect to my new laptop, even if only once, so that I can change/delete some songs and transfer a few dozen photos,since I haven't been able to do any of that stuff since my old laptop (that NEVER had any problems connecting) died way back in May! lol.                                                                                                                                                                                                 I hope somebody knows a fix or solution! Thank You!

    Try on another computer to help determine if iPod or computer problem.
    - Make an appointment at the Genius Bar of an Apple store.
      Apple Retail Store - Genius Bar

Maybe you are looking for

  • VL01N-Creation of Outbound Delivery, initial screen

    Hi, can anybody teach me how to gray-out or hide the "from item/to item" fields in the VL01N initial screen.

  • How to populate a list dynamically

    Being new b I am tasked on one project and I think I am making some progress on it. Currently I need to display some values in a list dynamically. The layout of the list is as follows: Here is your class schedule for week 05/13/2006: . Saturday . Sun

  • Will adobe creative suite 5.5 run on mac osx 10.9.4?

    We purchased the Creative Suite 5.5 with my daughter's last Mac laptop and now want to install it on her new MacBook Pro. This laptop does not have a DVD drive, though, so before we buy an external one, I wanted to verify that the software would inde

  • After 10.4.4 Update Flash Failes To Load In All Browsers!

    Has anybody experienced this problem?, Safari failed to load pluggin. even in IE, firefox and Opera no flash loads. Is there a fix for this? I have also downloaed the plugins and have re installed them varius times, and still no go. Its getting reall

  • Sync iCal with iCloud Calendar

    None of my appointments in iCal show up in my iCloud Calendar. In fact my iCloud Calendar has no appointments in it. I am sure I screwed something up in the coversion and trying to remove all the duplicate entries. In any event, how do I go about syn