Right way to close a dialog?

I'm working on an Application in which users update data in non-modal dialogs. We have been coding these dialogs as subclasses of JFrame. I know this sounds like a very-basic question, but I've searched stacks of books and numerous messages in this forum.
What's the correct way to close a dialog box. I need to achieve the following:
1. Free memory of the object that implemented the dialog box as well as any memory resources the system used to realize it on the screen. In other words, no memory leaks. (I assume setting defaultCloseOperation to WindowConstants.DISPOSE_ON_CLOSE would help with the memory cleanup).
2. I don't want to close down the entire application when someone clicks on the OK button. This, of course, rules out the technique used in all the single-screen Swing tutorials, which is to call System.exit(0).
Thank you so much!

hey tim. I had the same problem recently. try putting dispose(); in the action listener for your OK button. this should work!
greg

Similar Messages

  • I close out firefox the right way each time. Why dose it keep saying Opps seems firefox has crashed.. Every time...

    I have checked for all updates and there are none.. Why dose Firefox keep saying OPPPPPS well this is embarrassing , seems that your session has crashed.. Well I know it dose not crash because I close it out each and every time the right way....Can anyone tell me how to fix this issue.. It is really annoying.. Also I have tried each and everything I have found to try and nothing is working..

    hello Marlin29, this is currently a problem in firefox when you first close all open firefox windows and then close the application afterwards - the bug should be addressed in a later version of firefox.
    as a workaround in the meanwhile you could close firefox (through firefox > quit) while the browser window is still running or try this: enter about:config into the firefox location bar (confirm the info message in case it shows up) & search for the preference named '''browser.sessionstore.resume_from_crash'''. double-click it and change its value to '''false'''.

  • Pages 09 document; open and close many times; right way with Lion?

    I have a 106 page document that increases in size on a daily basis. With OS 10.7, iWork/Pages 09 on my new, iMac, it's common that I lose as much as two sentences after the document is closed and re opened. After 10.7 was installed the document was closed using Command - S, and subsequently closed by pulling down File and selecting Close. - Not the way to close; the red button was so easy with 10.6. IS UNINSTALLING LION THE BEST SOLUTION?
    And yes, I've read the sorry jibberish in the Pages 09 manual - which doesn't say how to open and close repeatedly a document with Pages 09.
    So, with the Lion - the worst ever of spending $30, is it necessary to do a Command S every time you close? And what exactly is necessary each time you close a document using Pages 09 and Lion? - And about Auto Save; well, what about Auto Save? - The Lion means well for something other than common, understandable, text production.  -- How about a separate application of Appleworks for text producers like me?

    The red button is always available under 10.7 (or 10.7.1)
    Under 10.7, press cmd + S once when you create the document.
    After that, the system automatically save your changes.
    No need for cmd + S.
    To close the document we may use :
    the red button
    cmd + W
    File > Close
    as it was with older systems.
    monte45 wrote:
    And yes, I've read the sorry jibberish in the Pages 09 manual - which doesn't say how to open and close repeatedly a document with Pages 09.
    The User Guide is perfectly clear and precise :
    Yvan KOENIG (VALLAURIS, France) jeudi 22 septembre 2011 19:21:52
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • Quickie - Stopping JFrames from minimizing when you close a dialog?

    Hi,
    As the subject bar suggests, there is probably a very quick solution to this:
    When I close dialogs that I have open, the parent JFrame minimizes to the taskbar. Its a bit annoying having to click on the taskbar to maximize it again. Is there a way of stopping this from happening? Thanks.

    Actually, you're right. After a little investigation, it was the way I was using the gui that was making this happen. During debuging (using Netbeans) I would open the dialog window then click on netbeans to check the console for a couple System.out.println()'s I put in the code. Then on closing the Dialog window Netbeans would be the next window selected by the OS and would appear over the original JFrame. D'oh! Just sillyness on my part imagining problems for myself.
    I guess what I was looking for was that when I close the dialog window that the OS would focus to the parent JFrame instead of the previously viewed application.
    Thanks!

  • How can I automatically close a dialog box using Javascript after I click the OK button to submit it?

    How can I automatically close a dialog box using Javascript after I click the OK button to submit it? I don't want to have to X out of the dialog box after I am done.
    Thanks
    Linda

    JS can not interact with open dialogs in any way, unless it's a dialog
    created in JS using the Dialog object.
    On Thu, Jul 24, 2014 at 11:13 PM, lindaeliseruble <[email protected]>

  • Right way to exit an applet

    Hi,
    I am making an applet by extending JApplet. Can anyone please tell what's the right way to stop the applet ie. to complete its execution.
    Shoud System.exit() be used, i tried stop and destroy , nothing happened. I have provided a menu inside my applet i want it to exit or complete execution with its window removed when some clicks on exit menu.
    Any suggestion is welcome.
    thanks
    inder

    Don't use System.exit in applet, won't work, and would probably throw a security exception.
    Only "destroy" your applet by overriding the destroy() method (where you do some clean up, close open connections, release references that takes a lot of memory, etc, nothing else). This method is called by the browser, at least when you close it.
    The stop() method should not try to destroy your applet. I think if the browser calls stop(), it will also call start() to start the applet again, but without calling the init() method. The init() method is called if the browser needs to run your applet first time, or again after destroy() has been called as far as I know.
    You can get more info if you read the javadoc comments for those methods.

  • What's the "right" way to create a News list in CQ5.4?

    Hey folks,
    I'm a brand new CQ developer and, though I've done a lot of reading, I'm still in the dark on how to do a few things.
    I'm currently working on a corporate website, and I need to build a News page. Each article contains a title and rich text (possibly including embedded images, videos, etc...), and the News page itself should display a paginated list of recent article summaries (with "read full article" links). I also need to show the two or three most recent article summaries on the site's front page, under a News heading.
    I thought there'd be a pre-built component to cover this case, since most corporate sites include a News page of some sort, but I haven't found one. Am I missing it? I looked into the Blog page template, but I think that adapting that may be overkill.
    I think that the right way to do this would be to build a News component with a Title and Rich Text field in the edit dialog. New articles could be created by dropping these components into the parsys of the News page. I could then create both a .html and a .summary view for the components and use a customized List component to display the summary list on the front page. Am I on the right track here, or am I overcomplicating it?
    Thanks!
    - Michael

    Hi,
    The "right" way of building any list-like component is to extend the existing List component.
    That is referenced in this documentation page:
    http://dev.day.com/docs/en/cq/current/wcm/default_components.html#List
    You can find it under /libs/foundation/components/lists
    To create, for example, a 'News List' component, just create a new component under your /apps/myproject/components, setting 'foundation/components/list' as sling:resourceSuperType ans add your custom script to display each news item. see also [1]
    That way you canprovide more renderers to be used around your site(s)
    [1] - http://dev.day.com/docs/en/cq/current/developing/components.html#Developing%20a%20new%20co mponent%20by%20adapting%20an%20existing%20%20%20%20%20component
    Hope this helps,

  • Often with 2 or 3 tabs/websites open, the tab does not have the X on the right side to close it. I have to right clock and hit Close Tab. Seems random. How can I assure all tabs have the X?

    Sometimes when I have 2 or more websites open, the tabs for them do not have the"X" on the right end that I can click to close them. Others right next to it may have the X or not - it seems random. The only way to close the x-less tabs is to right click and select Close tab. How do I tweak it so there are always X's? The only relevant add-on I can think of is Colorful Tabs, and I have the latest version of it.

    If you are not new to browsers, you would probably prefer the single "X" at the far right of the tabs bar to close the active tab, but in any case your choices are described for the configuration option of '''browser.tabs.closeButtons''', see
    * http://kb.mozillazine.org/Browser.tabs.closeButtons
    * Tabbed Browsing in Firefox<br>http://dmcritchie.mvps.org/firefox/tabs.htm
    * Tabs configuration, extracted from About:config entries - MozillaZine Knowledge Base<br>http://dmcritchie.mvps.org/firefox/tabs_config.htm
    '''More information on configuration variables''' if you are not already familiar with '''about:config''' is available in
    [http://kb.mozillazine.org/About:config_entries about:config entries] and for users not familiar with the process there is [http://kb.mozillazine.org/About:config about:config] (How to change).

  • The "right" way to handle multiple devices, accounts and the cloud?

    Perhaps a bit premature, but I figure it's never too early to start planning. 
    Here's our current setup - I currently have four iDevices in the faily (three iPhones and one iPod Touch.  All are syncing to the same Mac Mini, albeit with different logins (and different iTunes store ids).  All four of these are kept in sync via Home Sharing so we have access to the music/apps/etc acquired by the others.
    Enter the iCloud - how does this fit in?  What's the *right* way to do this? 
    I can see two options:
    1)     Continue to utilize four iTunes store ids, sync them via Home Sharing and add four iClouds
         Advantages
              totally independent devices, users, etc.
         Disadvantages
              must pay for four "iTunes Match" services to access non-iTunes music on each of the four devices
              will iTunes-purchased music automaticaly sync to iCloud if it is shared via Home Sharing (or only by the original purchaser)?
    2)     Use one iTunes Store id for all iDevices
         Advantages
              single point of acquisition and distribution for all devices
         Disadvantages
              need to find a way to merge IDs (is this even possible?)
    Are there other advantages/disadvantages to these options?  Are there other options?  What's the easiest to set up and support?  Any other thoughts?
    Thanks in advance for your input.

    Well it seems like the first thing you should do is consolidate your iTunes libraries so that you don't have 4 copies of everything, one for each user logged in to your Mac Mini. How you do that is consolidate all 4 iTunes folders to one folder located in the /Users/Shared/ folder and update each of your iTunes to point to that folder accordingly. That way you have one iTunes library, only one copy of your media, but accessible from multiple users.
    One caveat is that if somebody is logged on and has iTunes open, you can't fast switch to another user and open iTunes. Apple made it so that only one user and one instance of iTunes can open a iTunes library at a time.
    For your iTunes match situation, it does sound like you would be much better off sharing a single Apple ID with one iTunes Match. For consolidating, make sure you have everything everybody has shared via Home Sharing to the main account you'd like to move over to, and then simply go to each device Settings, Store, and the sign out of the original Apple ID and logon using the shared main Apple ID. I just looked at it and the automatic downloading is already live in iOS! You can specify if you want to do music, apps, and books separately in case you may want to automatically download music but not apps or books.

  • Problem with slideshow in iPhoto. Photos look like they are all the right way up but when in slideshow action some are sideways.

    even though all photos look like they are the right way up, when the slideshow commences, some of them display sideways. I have tried re-rotating them - and still have same problem. Help please - need it for Saturday night !

    What version of iPhoto are you using?  Are you creating the slideshow directly from an album or are you using the slideshow mode?
    As a test launch iPhoto with the Option key held down and create a new, test library.  Import some photos and test to see if the same problem persists. Does it?
    OT

  • How to create a custom panel in the right way (without having an empty panel in the file info) ?

    Hi Everyone
    My name is Daté.
    I'm working in the fashion industry as a designer and Design consultant to help fashion brands improving the design workflow by using Adobe softwares and especially Illustrator.
    I'm not a developper, but i'm very interested about the possibility to introduce xmp technology to provide more DAM workflows in the fashion industry.
    Fashion designers produce a lot of graphical objects in illustrator or Photoshop. Unfortunately they are faced to a big challenge which is about how to manage, search, classify and get this files faster. Of course PDM system or PLM system are used in the Fashion industry to manage data, but for many companies, implemanting this kind of database is very complex.
    When i look at what you can do with xmp, it seems to be an interesting way of managing design files, then i started to follow Adobe instruction to try to build a custom panel.
    The main idea is to (Theory) :
    create custom panels used by fashion designers to classify their design files.
    Use Adobe Bridge to search files, create smart collection to make basic reports in pdf and slideshows
    Find someone to make a script able to export metadata in xml files
    Use indesign and the xml file to generate automatically catalogues or technical sheets based on xmp values
    I have created a custom panel by using the generic panel provided by Adobe and i have modified the fields to feet with the terms used in the fashion industry and it works well.
    But unfortunately, when i try to create my own custom panel from scratch with Flashbuilder (4.6) and the Adobe CSExtensionBuilder_2 (Trial version), it doesn't work!
    Here is the process :
    I have installed flashbuilder 4.6
    I have download the XMP Fileinfo SDK 5.1 and placed the com.adobe.xmp.sdk.fileinfo_fb4_1.1.0.jar in C:\Program Files (x86)\Adobe\Adobe Flash Builder 4.6\eclipse\plugins
    In Flashbuilder, i have created a new project and select xmp Custom panel
    The new project is created in flashbuilder with a field with A BASIC Description Field
    To generate the panel, right click the project folder and select xmp / Publish Custom Panel
    The panel is automatically generated in the following folder : C:\Users\AppData\Roaming\Adobe\XMP\custom file info panels\3.0\panels
      Go to illustrator, Open the file Info
    The panel appears empty
    The others panel are also empty
    The panel is created and automatically placed in the right folder, but when you open it in Illustrator by selecting the File Info option in the File Menu, this custom panel appears empty!!! (only the title of the tab is displayed). This panel also prevent the other panels to be displayed.
    When you delete this custom panels from the folder C:\Users\AppData\Roaming\Adobe\XMP\custom file info panels\3.0\panels and go back to the File Info, the other panels display their content properly.
    I also try to use the plugin XMP Namespace designer to create my own namespace. this plugin is also able to generate a custom panel, but this one also appears empty in AI or Photoshop.
    I try to follow the process described in Adobe xmp documentation many times, but it didn't works.
    It seems that many peaople have this issue, but i dodn't find a solution in the forum.
    I try to create a trust file (cfg), but it didn't work.
    It would be so kind if you can help me to understand why i can't create a custom panel normally and how to do it in the right way.
    Thanks a lot for your help,
    Best regards,
    Daté 

    Hi Sunil,
    After many trial, i realize the problem was not coming from the trust file, but from the way i have created the custom panel.
    There is 2 different ways, the first described below is not working whereas the second is fine :
    METHOD 1 :
    I have downloaded the XMP-Fileinfo-SDK-CS6
    In the XMP-Fileinfo-SDK-CS6 folder, i copied the com.adobe.xmp.sdk.fileinfo_fb4x_1.2.0.jar plugin from the Tools folder and i pasted it in the plugind folder of Flashbuilder 4.6
    The plugin install an XMP project
    In Flashbuilder 4.6 i have created a new project (File / New /Project /XMP/XMP Custom Panel)
    A new xmp project is created in flashbuilder.
    You can publish this project by right clicking the root folder and selecting XMP / Publish Custom Panel
    The custom file info panel is automatically published in the right location which is on Mac : /Users/UserName/Library/Application Support/Adobe/XMP/Custom File Info Panels/3.0 or /Users/UserName/Library/Application Support/Adobe/XMP/Custom File Info Panels/4.0
    Despite the publication of the custom file info panel and the creation of a trust file in the following location : "/Library/Application Support/Macromedia/FlashPlayerTrust", the panel is blank in Illustrator.
    I try this way several times, with no good results.
    METHOD 2 :
    I have installed Adobe CSExtensionBuilder 2.1 in Flash Builder
    In FlashBuilder i have created a new project (File / New /Project /Adobe Creative Suite Extension Builder/XMP Fileinfo Panel Project)
    As the system display a warning about the version of the sdk to use to create correctly a custom file info, I changed the sdk to sdk3.5A
    The warning message is : "XMP FileInfo Panel Projects must be built with Flex 3.3, 3.4 or 3.5 SDK. Building with Flex 4.6.0 SDK may result in runtime errors"
    When i publish this File info panel project (right click the root folder and select Run as / Adobe illustrator), the panel is published correctly.
    The last step is to create the trust file to display the fields in the panel and everything is working fine in Illustrator.
    The second method seems to be the right way.
    For sure something is missing in the first method, and i don't understand the difference between the XMP Custom Panel Project and the XMP Fileinfo Panel Project. Maybe you can explain it to me.
    So what is the best solution ? the right sdk to use acording to the creative suite (the system asks to use 3.3 or 3.5 sdk for custom panels, so why ?)
    I'm agree with Pedro, a step by step tutorial about this will help a lot of peaople, because it's not so easy to understand!!!
    Sunil, as you belong to the staff team, can you tell me if there is  :
    A plugin or a software capable to extract the XMP from llustrator files to generate XML workflows in Indesign to create catalogues
    A plugin to allow indesign to get custom XMP in live caption
    A plugin to allow Bridge to get custom XMP in the Outputmode to make pdf or web galeries from a smart collection
    How can you print the XMP data with the thumbnail of the file ?
    Thanks a lot for your reply.
    Best Regards
    Daté

  • Right way of configuring higher MTU over a Port Channel

    Hi guys,
    I have a running critical Port-Channel between two locations.
    Here's the config
    SW1:
    interface Port-channel2
     switchport
     switchport trunk encapsulation dot1q
     switchport mode trunk
    end
    interface GigabitEthernet1/45
     switchport trunk encapsulation dot1q
     switchport mode trunk
     channel-protocol lacp
     channel-group 2 mode active
    end
    interface GigabitEthernet1/46
     switchport trunk encapsulation dot1q
     switchport mode trunk
     channel-protocol lacp
     channel-group 2 mode active
    end
    SW2
    interface GigabitEthernet1/1
     switchport trunk encapsulation dot1q
     switchport mode trunk
     channel-protocol lacp
     channel-group 2 mode passive
    end
    interface GigabitEthernet1/2
     switchport trunk encapsulation dot1q
     switchport mode trunk
     channel-protocol lacp
     channel-group 2 mode passive
    end
    interface Port-channel2
     switchport
     switchport trunk encapsulation dot1q
     switchport mode trunk
    end
    Now I need to increase the MTU from default value to 9198. What the right way to do it and avoid any connectivity loss, PortChannel restart.
    Does it matter what switch I start first?
    Thanks!
    L.E. both SW are WS-C4948

    Hi,
    Because you are using layer 2 interfaces - there is no fragmentation support at layer 2, and interfaces receiving frames which have an unsupported size will be dropped.
    I think the best way for you to proceed is to lab this up; and verify what happens - it may be that you need to make changes on switches at either end of the channel within a very short time frame to prevent too large an outage.
     When you are ready to maike your change - think the best way to do this is to use the interface range command, and apply the 'mtu' command to all the interfaces in this range. I don't think it matters which switch you apply this change to first, and I don't believe if you are hinting at the 802.3ad (controlled by system-priority) decision maker, that it makes any difference.
    HTH
    Mike

  • Right way of login form...

    Hello
    I am a really newbie in web programming. I want to write a web application with JSF. I wonder what is the rgiht way of creating the login form. I tried to write a page segment file for it but page segments do not have prerender method so it cannot be fully controlled...I want something like that:
    login control will be two parts..
    if login info is not found in session, than it will show the login form.
    if the user is found in session, than it will show the menu for the user...
    but i couldnt do that because prerender methos is not available in page segments..
    what is the right way for doing that kind of thing?

    Indeed implement a Filter.
    Once an user logs in, put the User object in the HttpSession. Let the filter check on this User object. If this User object is null and you're not in the login page, then redirect to the login page.
    Do a Google search on "LoginFilter implements Filter" or "UserFilter implements Filter" and you'll find lot of examples.
    http://www.google.com/search?q=%22LoginFilter implements Filter%22
    http://www.google.com/search?q=%22UserFilter implements Filter%22
    Here is an advanced one which actually doesn't redirect if the User object doesn't exist, but this might give you some new insights: http://balusc.xs4all.nl/srv/dev-jep-usf.html

  • Right way to dispose frame/components/containers?

    Hi,
    My application creates a lot of frames with lots of containers and components (heavyweights as well as light weights) inside them. I have obeserved that none of the frames/containers/components get finalized unless I do a remove/removeAll() over the respective container. Currently I just make a call to frame.dispose() to dispose it off and assume that all components would be reclaimed by the garbage collector at some point of time. Is that the right way to dispose off the frames and mark all its child components for garbage collection? Or is an explicit call to removeAll() required to release the memory. I am aware that garbage collection doesn't happen immediately and may take a while before the GC collects objects. I have run the application continuously for couple of hours and created/disposed a lot of frames during that period. GC recollected none of them (none of the components either) except for those that were removed by an explicit call to remove or removeAll during the lifetime of the session. I even hit OOM errors but none of the components were recollected.
    What could be the problem?
    Some additional information:
    I overridden removeNotify() and finalize() methods to see what's going on. For all components removeNotify() was called (even if I don't do explicit remove/removeAll and just dispose off the frame) but finalize never gets called. My methods:
         public void removeNotify()
              super.removeNotify();
              System.out.println("Remove notify called "+compId);
         protected void finalize() throws Throwable
              super.finalize();
              System.out.println("Finalized component "+compId);
         }Thanks in advance.
    Edited by: crack_it on Jul 31, 2009 8:52 AM

    Sorry to bother guys. The problem was not with AWT but with one evil component that was displayed inside most of my Frame classes and was also registered as an Observer with an Observable class. The event at which the component was supposed to unregister itself with Observable never got fired and this one reference prevented garbage collection of entire gui brigade. Damn! Tiny monster.
    Anyway the issue stands resolved. Thanks for your time.

  • Right way to validate form fields !!

    Hi,
    I am having a form with many fields including TextFields, Dropdowns, DateFields, Checkboxes, Radiobuttons etc.
    I am validating the most fields by making them REQUIRED. But I didn't found way to make Checkbox field required. So I am doing it by script by making its MANADATORY property to true. I am validating fields at the Form's preSubmit event.
    All I want to know that whether it is the right way to validation i.e.
    Making field.mandatory = true; (for checkboxes or may be some other field too)
    Check it at preSubmit event of the form;
    I want to code it according to best practices. That's why this question bounces up in the mind.
    Thanks.
    Abhinav

    Thank you for your replies!
    I understand how to get data into a JCombobox,
    but what about my bigger, general question?
    "I am confused because in other parts of my program I get a database connection and am not sure if you just form a query each time you need data or store the results somewhere (vector, array, collection)and use it this way." when the data or parts need to be used again.
    This is the help I need.
    Thanks again1
    Alan

Maybe you are looking for