• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFrame or JDialog

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my history of writing Swing apps if I needed to spawn additional windows for whatever reason off my main JFrame I have just always used a JDialog. But none of them are modal. So I'm wondering if, aside from the modal part which I don't use, is there any advantage/disadvantage to using a JDialog instead of a JFrame for extra windows? Or am I just the same using a JFrame.
Thanks.
 
Fuqiang Zhao
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Frame can be maximum and minimum and dialog cannot, in office software, it cannot use multiple document interface, just open new frame for every file, in this case, you cannot use dialog.
In other case, use dialog is preferred.
 
Jason Steele
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg,
I only use JDialogs for preference boxes, login boxes, etc. The main reason I use them is for their automatic blocking. Of course, for them to block, you have to set them modal.
Good Luck!
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Greg,
I think it depends a bit on your users. My users are average office admin types. I have used JOptionPane but found that most of my users would eventually complain that my app froze. In about three cases where I was able to investigate, I found that they had somehow managed to hide the dialog box behind the main app which then appeared dead. I could get to the dialog box with alt tab but this is not something I could expect the users to do. I have not been able to duplicate this behaviour for myself but I am now rather more reluctant to use modal screens.
My app (about 10 screens) is now arranged as a tabbed pane and that has been pretty successful.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main reason I use them is for their automatic blocking
As I said, none of mine are going to be modal so I don't have to worry about that issue.
I have used JOptionPane but found that most of my users would eventually complain that my app froze
Did I say something about a JOptionPane in my question? BTW - The reason your users are having that problem is because you aren't specifying the parent frame for the JOptionPane to be modal to. If you specify the parent frame the JOptionPane cannot get lost behind it.
The Frame can be maximum and minimum and dialog cannot,
This seems the only valid reason so far however, I can disable window decorations on my JFrame and then the user won't be able to minimize/maximize. So does anyone else have any viable reasons?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic