MichalB
MichalB

Reputation: 3341

Should I use JFrame or JDialog?

In my GUI, by clicking on the button "Help", I want to open a new window within it containing som text information stored in HTML via JEditorPane. My question is:

  1. Should I store an instance of JEditorPane object within JDialog or JFrame?
  2. What kind of pros/cons both components can offer?

I do not want to make any operations within this window, it will just serve to show the text information.

Upvotes: 0

Views: 1760

Answers (1)

bpoiss
bpoiss

Reputation: 14023

The differences between JDialog and JFrame are, that JDialog has no maximize/minimize button, and you can not set a DefaultCloseOperation on it.

Also a JDialog blocks other components until it is closed (it waits for userinteraction). So if you use it as "Help" window, the user could not leave it open in background and continue working with your application.

If the user can only read your info text, and can not interact with your help, you should use a JFrame.

A JDialog should be used if the user has the choice e.g. of pressing Ok or Cancel, and he should not be able to do anything before he has choosen something.

Upvotes: 2

Related Questions