This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

create a JDialog that is modal?  RSS feed

 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i tried to create a class that extends from JDialog
from another class :


but how can i make it as modal?
 
Sainath Veepuri
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,
Your dialog is no doubt a modal dialog since you have chosen as true, but there is no parent(owner) on which the dialog should act as a modal dialog.
Give a proper parent(current owner) reference instead of null on which the dialog is popped up.
Hope this helps.
Thanks,
SAi.
 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hihi,
it doesnt work.

this is the class which extends from JDialog.


this is the controller class which makes the JDialog.

 
Sainath Veepuri
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi kelvin,

1) Your code will not compile, since instead of boolean you have used Boolean in the constructor.

2) I didnot see any owner showing before your dialog is popped up. A dialog can act as a modal dialog, only if the parent(current owner) mentioned inside the constructor is showed first and then the dialog is showed up.

Try this:
=======================================================
public static void main(String[] args) {
Frame f = new Frame();
f.setSize(500, 500);
f.setVisible(true);
new studOversiktVindu(f,true);
}
========================================================
Hope you would understand this time either.
SAi.
 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Sai!
I understand now
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!