Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

using dialogs  RSS feed

 
Randall Twede
Ranch Hand
Posts: 4585
6
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i just used the standard dialogs(showXXXDialog()) i didn't worry about it. now i am using custom dialogs and there are two basic ways to do it. i am doing it by creating a new dialog each time the menu item is clicked. the dialog sets it's close action to dispose and the cancel button calls dispose(). i think this has an advantage because if you never choose that menu item the dialog never gets created. the alternative is to just create one at startup and change it's visibility. which is better? a bigger question is what is happening in the standard dialogs when they go away? are they disposed.? the default for JDialog is to hide.
 
Randall Twede
Ranch Hand
Posts: 4585
6
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i figured out the first question during my beer break. in this situation i want the user to get a new slate each time. if i did it the other way, after he did a find and replace, then went about his business, then did another find and replace, when the dialog showed, the text fields would already have the old values in them. not desireable. so the make it a member variable thing is for if you want to maintain stuff between dialog sessions.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds rather like you're mixing the model and view. State should be persisted in the model; the view (member variable or newly instantiated local variable, doesn't matter) just reflects the current state of the model.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!