Results 1 to 3 of 3
Like Tree2Likes
  • 1 Post By kjkrum
  • 1 Post By sunde887

Thread: Is this the equivalent of wearing both suspenders and a belt, or something worse?

  1. #1
    blackbird is offline Senior Member
    Join Date
    Jul 2011
    Posts
    100
    Rep Power
    0

    Default Is this the equivalent of wearing both suspenders and a belt, or something worse?

    I have two pieces of window "closing" code:

    1)
    Java Code:
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    2)
    Java Code:
    frame.addWindowListener(new WindowAdapter() {
    			public void windowClosing(WindowEvent e) {
    				try {
    					socketDispatchFile.close();
    				} catch (Exception exception) {
    				}
    				System.exit(0);
    			}
    		});
    Does one obviate the other? IOW, should I get rid of the first one when using the second one?
    Last edited by blackbird; 07-21-2011 at 06:50 PM. Reason: I forgot to enclose the code in [CODE]

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default

    I'm not sure which takes precedence over the other. I suppose you could write a test program to find out. But either way, I think the answer to your last question is yes.
    blackbird likes this.
    Get in the habit of using standard Java naming conventions!

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Your code already exits so it's a waste to have the default close operation set.
    Last edited by sunde887; 07-22-2011 at 02:11 AM.
    blackbird likes this.

Similar Threads

  1. Equivalent of PHP isset in JAVA
    By africanhacker in forum New To Java
    Replies: 11
    Last Post: 03-24-2011, 02:41 PM
  2. Machiuke equivalent in J2ME
    By kimhonoridez in forum New To Java
    Replies: 3
    Last Post: 01-07-2011, 01:50 AM
  3. VB Net FIX equivalent?
    By bullstreetboy in forum New To Java
    Replies: 3
    Last Post: 04-06-2009, 05:31 PM
  4. Replies: 1
    Last Post: 11-21-2007, 12:18 PM
  5. Asteroid Belt 0.0.1
    By Jamie in forum Java Software
    Replies: 0
    Last Post: 06-14-2007, 03:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •