Why do we have to call SwingUtilities.invokeLater()??

Hello,
i am not understanding the concept of SwingUtilities.invokeLater() i read the documentation but still couln't get why it is needed and when it is needed?do we have to call this function everytime some event is generated and some action is performed on component Ex.mouse click on button etc?? Please give me little details regarding it's concept!
Thanks in advance :)

(guys correct me if i'm wrong here)Most of the time that's correct, but for some customizations it is necessary to run custom code after all default code contained in the Swing classes has been executed. For example, to request focus be given to a component that would otherwise not be immediately focused, if you omit to enclose that in a invokeLater, it will get the focus but immediately lose it as still-queued events mandate the transfer of focus elsewhere. Moreover, as the event delivery mechanism is asynchronous, the behavior may be inconsistent.
In general, any customization that may conflict with the normal flow should be wrapped in invokeLater, whether run from the EDT or another thread. The exceptions here are methods which the API declares to be thread safe.
what you want to do is run that time consuming process in a thread, and when you need to call back to update the GUI, then use SwingUtilities.invokeLater.Or use SwingWorker, that's what it's for.
cheers, db

Similar Messages

  • Why do we have to use SwingUtilities.invokeLater() to update UI status?

    I just don't understand very well why we have to use SwingUtilities.invokeLater() to update UI status. Why not just new a thread in actionPerformed() method and do time consuming tasks in this thread and update UI status in it? Some tutorials say it is not safe to update UI status not in Event Dispatch Thread, I don't understand, why is it not safe? Can anyone provide a scenario for this? I just write an example, a button and a progressbar, click button, progressbar keeps updating value. I just create a new thread to do this, don't find any issue. Thanks.

    [Swing single threaded rule|http://www.lmgtfy.com/?q=swing+single+threaded+rule]
    db

  • Why Do We Have To Call super.init(config); in init() method of servlet?

    Hi, everyone..
    I wonder why we call super.init(config) in init method of servlet... If i dont call it ; when i try to get servletcontext in service method it throws java.lang.NullPointerException...when we call super.init() , what is happening behind the scene? If anybody has a technical explanation for my question , i will be very pleased...
    THX FOR YOUR FUTURE REPLIES IN ADVANCE....

    I am sorry about the uppercases and i dont want to seem smart on java forums... Anyway, m8 this is the thing that i know... i meant; for instance when we override doGet or doPost method ; we dont need to override init method; but the server loads the servlet and we can get the context of the servlet in these methods easily by calling getServletContext() method; however when we want to call service method implicitly by jndi, servlet needs to be loaded and init method must call its parent...(i also write down in web.xml <load-on-startup>.... for that servlet).
    thx for your replies in advance....

  • HT1349 WHY DO I HAVE TO CALL SUPPORT WEEKLY

    I cannot rebt or buy movies on my apple TV.  I have to contact support weekly,  They reset and everything is fine.  I can't imagine how much money you are losing, because customers like me cannot purchase.  BIG PROBLEM!

    This is a user forum, you are not addressing Apple.
    If you wish to isolate the problem please give more information on your issue. It's typically network related.

  • When bluetooth headset is connected to iphone,I can't hear iphone ringing aloud when I have a call or a text. Do i really have to wear the bluetooth headset all the time in my ear to know when I have a call or a message? Why it doesnt ring through iphone?

    when bluetooth headset is connected to iphone,I can't hear iphone ringing aloud when I have a call or a text. Do i really have to wear the bluetooth headset all the time in my ear to know when I have a call or a message? Why it doesnt ring through iphone but it rings through the bluetooth headsets?
    In other phones, you can hear the phone ringing and if it was connected to bluetooth, you could pick up the call from the bluetooth headset.
    Here with iphone, if its connected to bluetooth headset, it only rings through the headset, which means that if you dont have the headset in the ear all the time, you cannot know that you have an incoming call or message.
    Any ideas - solutions - comments please?

    I'm having the same problem. I had a plantronics 975 (which I lost, sadly). When connected, the ringer would always be routed through the bluetooth and the iPhone's external speaker. When in silent mode, the iPhone would only vibrate, but I could still hear the ringer in the bluetooth.
    I just bought a new Plantronics Voyager+. Now when it's connected, all sounds are routed to the earpiece - including the taps, etc. The iPhone's speaker doesn't ring at all, unless the bluetooth is disconnected or powered off. I'd really like to be able to hear both, like I was before. This is an iPhone 3G running iOS 4 (latest version, not sure what it is exactly). Haven't updated software/firmware in between bluetooths, just changed the earpiece.

  • When I start firefox, i get this message ( The instruction at "0x7b9c77a9" referenced memory at "0x7b9c77a9". The memory could not be "read" ) hs anyone any idea why? I have scanned with AVG and something simply called 'Trojan Remover' and they both fin

    when I start firefox, i get this message ( The instruction at "0x7b9c77a9" referenced memory at "0x7b9c77a9". The memory could not be "read" ) hs anyone any idea why? I have scanned with AVG and something simply called 'Trojan Remover' and they both find nothing.... any advice would be greatly welcomed.. thanks
    == This happened ==
    Every time Firefox opened
    == this morning 22/07/10

    Lyall,
    I have seen this before, a long time ago (several years), and I cannot
    remember how/if we resolved it.
    If this is an impotant issue to you, I suggest that you open a case with
    BEA support.
    Regards,
    Peter.
    Got a Question? Ask BEA at http://askbea.bea.com
    The views expressed in this posting are solely those of the author, and BEA
    Systems, Inc. does not endorse any of these views.
    BEA Systems, Inc. is not responsible for the accuracy or completeness of
    the
    information provided
    and assumes no duty to correct, expand upon, delete or update any of the
    information contained in this posting.
    Lyall Pearce wrote:
    The title says it all really.
    I see other posts getting replies.
    This is a rather important issue, I have seen another post with a similar problem.
    While not being a show-stopper it certainly raises concerns.
    The application works ok until the application exits (in both development and
    executable form)
    Apparently this did not happen with Tux 7.1
    It does with 8, I do not have 7.1 so I have no workaround.
    ..Lyall

  • Why doesn't the iPhone 5 have the call bar feature like the 4S does?

    Why doesn't the iPhone 5 have the call bar feature like the 4S does?

    From the Swype website:
    Why isn’t Swype available for iPhone/iPad/BlackBerry/Windows Phone?
    Due to the technical design of some operating systems, it is not possible for third party keyboards (such as Swype) to be offered at this point in time. Please communicate to your device/OS manufacturer that you’d like to see Swype available as a keyboard option!
    Here is the link:
    http://www.swype.com/about/swype-faq-3/
    Cheers,
    GB

  • Why doesn't the Verizon Version of the HTC ONE (M9) have Wifi Calling?

    I have been with sprint for 11 years and recently upgraded my HTC One (M7) to the HTC One (M9). went to jamaica and was able to keep in touch with everyone free of charge with wifi calling. Once i returned i decided to leave sprint and come to Verizon. I realized today they dont have wifi calling on this phone. Why is that. isn't it CDMA like sprint

    They're planning on releasing it in mid-2015:
    Verizon Wireless (NYSE: VZ) plans to introduce Wi-Fi calling in the middle of next year but does not see an urgent need for it, according to Verizon Communications CFO Fran Shammo.
    Speaking at the Bank of America Merrill Lynch Media, Communications and Entertainment Conference, Shammo noted that Apple's (NASDAQ: AAPL) new iPhone 6 and 6 Plus support Wi-Fi calling. He said Verizon needs to do "some technological work in our network to make it available," and it should come around the middle of next year.
    However, he said Wi-Fi calling was "never a top priority" for Verizon. "We built our voice platform so extensively [that] there was never a need for us to tell our customers, 'Oh, our network is not good enough so you need to go on Wi-Fi to complete your call.'"
    He noted that when a call goes onto a Wi-Fi network, it's difficult for Verizon to guarantee the quality of service on that call, which is what Verizon has built its brand reputation on. That's a major reason Verizon waited so long to launch Voice over LTE service--it wanted to make sure it had adequate coverage that could replicate the voice experience of calls on its 3G CDMA network. Verizon has just started rolling out VoLTE service.
    Other carriers are moving ahead with Wi-Fi calling plans. Ralph de la Vega, CEO of AT&T's Mobile & Business Solutions Group,  said last week that AT&T will launch Wi-Fi calling in 2015 but that the carrier will use it only as a complement to Voice over LTE or 3G-based calling. "We don't have this burning desire" to use it to enhance coverage, he said.
    The comments were notable in light of T-Mobile US' (NYSE:TMUS) announcement this week that heavily emphasized Wi-Fi calling and using personal routers to create Wi-Fi coverage areas in subscribers' homes. T-Mobile is the first and only U.S. carrier to support Wi-Fi calling on the new iPhone. Sprint (NYSE: S) also launched a Wi-Fi calling service for its Android smartphones this past February.
    In terms of other hot topics, Shammo said Verizon would not be leasing phones, as Sprint is doing with its "iPhone for life" offering with the new iPhones. Under that program, individual customers will pay $20 a month for a 16 GB iPhone 6, instead of $30 under normal financing. At the end of 24 months, they can trade in their iPhone for a new iPhone. The iPhone 6 Plus will cost $25 per month under this program instead of $35 under normal financing. If a customer wants an iPhone with more internal storage they will pay more per month. The leasing program applies to families as well.
    Shammo said Verizon offers its Edge handset-financing and early-upgrade program but that the "majority" of Verizon customers are still choosing subsidized handsets paired with two-year contracts. In contrast, AT&T said sales through its similar Next program represented around 50 percent of all smartphone sales in the second quarter.
    Shammo also touched on whether Verizon might sell its wireless-tower assets, saying the company remains open to it. In the past, doing a deal "always came down to price and terms and conditions," which he said have become more favorable. He said that Verizon's network is experiencing high demand and that the company would like to retain the flexibility to add towers or add network gear to existing towers. "It's an option for us," he said. "We continue to look at it, and we'll see what happens."
    Last week at a separate investor conference, Verizon Communciations CEO Lowell McAdam also said the company would be open to selling some of its towers if the price was right. "Those deals are coming to us a little more now, and if an opportunity presented itself to increase shareholder value" Verizon would be interested in pursuing it, McAdam said, according to Reuters. McAdam said Verizon received interest in its towers two years ago, but the bids weren't high enough.
    http://www.fiercewireless.com/story/verizon-wireless-plans-launch-wi-fi-calling-mid-2015/2014-09-17

  • Why do I have to reboot the iPad to receive FaceTime calls?

    Why do I have to reboot the iPad to receive FaceTime calls?

    Razmee, many thanks for your correct advice.  You are a STAR.  So nice now to be able to get the Internet all the time.  Great advice.

  • Why the iPhone dose not show the witting in case if the other person have a call and I'm on witting?

    Why the iPhone dose not show the witting in case if the other person have a call and I'm on witting? really I'm dissappointed with this point Why we do not have this service?

    That is not a feature of the iPhone (or of any phone I've ever had so apparently it's far from universal). Apple has not said why they have no such feature.
    You can request such a feature here:
    http://www.apple.com/feedback
    Either the person you're calling will answer you or they won't. What difference does it make why?

  • Why sony phones doesn't have video calling options through 3g??

    Why sony not providing video call support through 3g.. In samsung we can call and its supported for all phones which have front facing camera.. thats a fault... Im a very interested one in sony products.. But this... Can you bring this feature in next update??

    To support uli's words:
    https://talk.sonymobile.com/t5/Xperia-mini-pro/3g-Video-Calling/m-p/104693#M2691
    https://talk.sonymobile.com/t5/Xperia-Z-ZL-ZR/3g-video-call/m-p/952159#M56280
    Topic closed.
    All we have to decide is what to do with the time that is given to us - J.R.R. Tolkien

  • HT1349 Why doesn't Iphone have a call blocker, I am getting tired of paying for phone scam calls, why dpesn't someone make one.  When my contract is up I am going back to the Droid.

    Why doesn't Iphone have a call blocker, I am getting tired of paying for phone scam calls, why dpesn't someone make one.  When my contract is up I am going back to the Droid.

    dshargrove wrote:
    Why doesn't Iphone have a call blocker, I am getting tired of paying for phone scam calls, why dpesn't someone make one.  When my contract is up I am going back to the Droid.
    For one thing, true call blocking (ie. where the call NEVER actually connects through to your number) can only be done by the service provider at their switches.
    The best a device can do is allow the call to connect, and then use the caller ID information to compare that to a list of allowed and a list of disallowed caller IDs.  That is a feature known as blacklisting, but it is not the same as actually blocking a call completely.
    So as suggested, contact your carrier and ask what they can do for you.

  • Why do I have to dial a "1" before making long-dista​nce call

    I have the FiOS bundle (phone, internet and tv).  In order to redial calls coming from caller ID I often have to add a 1 to the number.  So when I go to dial from my caller ID I have to write down or memorize the number and then add a "1" to the front of it, which I never had to do with Comcast.
    Two questions:
    1. Why do I have to dial a "1" before the phone numbers?
    2. Does Verizon charge for long-distance?
    If you are the original poster (OP) and your issue is solved, please remember to click the "Solution" button so that others can more easily find it.
    If anyone has been helpful to you, please show your appreciation by clicking the "Kudos" button.
    Solved!
    Go to Solution.

    The FCC categorizes Verizon as an 'ILEC' (Incumbent Local Exchange (telephone) Company; this means that they existed prior to the Bell System divestiture in 1984 and are required to observe certain operational standards to permit reasonable interconnectivity with their network(s) and any new 'CLEC' Competitive Local Exchange (telephone) Company.  Comcast is considered to be a 'CLEC' and as such only has to adhere to such standards to permit their connection to the public switched network.  Comcast is also a VOIP provider and thus creates many of its own rules as it sees fit --VOIP providers use many proprietary rules.  While this may seem advantageous to many people, it does create consumer confusion such as you have encountered with the 1+ access.
    In reality, it is an old remnant from electromechanical switching systems (pre- electronic switches) and is not really needed in today's network.  In fact, many US localities have a 1+ 'permissive' dialing plan --meaning the call will go through with, or without, the 1+ (cellular does in fact work permissively).  The likelihood of the 1+ access changing in the near future is nil.
    That all said, depending on the telephone set(s) you have it is possible to dial a 1+ call from a Caller ID list --some sets even have a menu option to cause all calls to have a 1+ prefixed.  Or, you could simply dial the 1+; then scroll to the desired Caller ID number and select it.  I do this all of the time.

  • Why do I have to hit keypad and 1 to answer a call?

    why do I have to hit keypad and 1 to answer a call?

    No idea. Ask your carrier. That's not normal. Sounds like you may have Google Voice forwarding calls to you or something...

  • Why I phone doesn't have a call blocker

    Why can we block unwanted calls, lots of phones have this mode but no  I phone.

    This has been discussed a couple times in the past few months...Apple has just not incorporated the call block procedure in the iOS.  If you really want it, give Apple feedback:
    http://www.apple.com/feedback

Maybe you are looking for