Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Multiple swing Windows
Index -> Programming, Java -> Java Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
deville75




PostPosted: Thu Mar 09, 2006 1:20 am   Post subject: Multiple swing Windows

It's been a while since i've done swing and the experience i have itself isnt very much. I have a program that opens multiple windows, but wen i close one all of them close. How do I close only one at a time?
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Thu Mar 09, 2006 1:49 am   Post subject: (No subject)

Obviously somewhere you've said that the window-closing event for any oif the windows terminates the entire application. Only set this for a "main" window.
deville75




PostPosted: Thu Mar 09, 2006 1:01 pm   Post subject: (No subject)

ok i think i've found out how. I'm just wondering if this is an efficient or valid way, becuase sometimes things work even tho it shouldn't be done that way.

Basically the program would make instances of other classes that would open a new window. So i had one class called Mainform and when u clicked on one of the buttons it created a new object of the class NewWindow for example, which would open a new window. At first, I had the following code in both of the classes:


code:
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);



but now i deleted this from the NewWindow class and it works like it should. Is this proper?
wtd




PostPosted: Thu Mar 09, 2006 1:08 pm   Post subject: (No subject)

You tested it. It worked. Why ask me if it's proper or not? Smile

You have to have confidence in your code. You have to be willing to stand up to a challenge and say, "yes, my code does work!"

Of course, you also have to be ready to be wrong from time to time. Wink

Yes, removing that is fine.
Justin_




PostPosted: Thu Mar 09, 2006 8:44 pm   Post subject: (No subject)

That's shocking coming from you wtd. You give the impression that it's best to follow the standards...
wtd




PostPosted: Thu Mar 09, 2006 8:58 pm   Post subject: (No subject)

Where am I advocating something non-standard in this thread?

Some of your posts lately have been really odd, Justin_. Please give more thought to them in the future.
Justin_




PostPosted: Thu Mar 09, 2006 9:07 pm   Post subject: (No subject)

Yeah, maybe something is wrong with me cause I don't see how you don't understand what I mean. The guy asked if his way of doing things was standard, essentially. And you replied with an uplifting speech about how he should go about and do his own thing with confidence as long as it works.
wtd




PostPosted: Thu Mar 09, 2006 9:11 pm   Post subject: (No subject)

There is no one set way of doing things when the behavior desired varies. Is he using weird code not included in the standard library? If not, then yes... there's an issue with standards, but otherwise, if it works, go with it.

Of course, there might be better ways to get the job done, but that doesn't mean the first attempt was wrong.
Sponsor
Sponsor
Sponsor
sponsor
Justin_




PostPosted: Thu Mar 09, 2006 9:17 pm   Post subject: (No subject)

Yes but imagine you were new to programming and you put together a method of doing something but were unsure if it was considered proper, or standard, or whatever you want to call it. Essentially something that isn't frowned upon by other programmers. And to take a shortcut, you decided to ask a gifted programmer if it was okay to do something in such a way. What you said about confidence, although its okay to be confident, in the end all confidence will do is slow you down. If you're using deprecated code without realizing it, the longer you wait to learn the contemporary, the longer you are wasting your time.

I think its perfectly valid to ask if something is okay. Especially if you're new.
wtd




PostPosted: Thu Mar 09, 2006 9:19 pm   Post subject: (No subject)

It is... however...

If you write some code, and it works, then do not ask me if it works. Smile
Justin_




PostPosted: Thu Mar 09, 2006 9:23 pm   Post subject: (No subject)

Quote:

Code:
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);



but now i deleted this from the NewWindow class and it works like it should. Is this proper?


Good thing no one asked you if it works.[/quote]
wtd




PostPosted: Thu Mar 09, 2006 9:33 pm   Post subject: (No subject)

Oh, and I did answer the question. Perhaps you would care to read my posts.

Please do not try to flame me.
Justin_




PostPosted: Thu Mar 09, 2006 9:48 pm   Post subject: (No subject)

Redherring are we?

Quote:
If you write some code, and it works, then do not ask me if it works.


I was merely responding to your statement. I wouldn't flame you, but we are in a kind of debate here.
deville75




PostPosted: Sat Mar 11, 2006 2:05 pm   Post subject: (No subject)

LOL

OMG Shocked WUT HAV I STARTED!
wtd




PostPosted: Sat Mar 11, 2006 2:09 pm   Post subject: (No subject)

It's not your fault. Smile
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 18 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: