participate


Java Desktop Applications - Frames and modal/non-modal dialogs
<<   Back to Forum  |   Give us Feedback
This topic has 7 replies on 1 page.
miltonxp
Posts:4
Registered: 9/19/02
Frames and modal/non-modal dialogs   
Jan 9, 2004 7:54 AM

 
I have a swing application that has many frames and dialogs. Is it possible to make a dialog modal for some frames and non-modal for the others frames?

Thanks.
 
Boris_Fly
Posts:15
Registered: 8/11/03
Re: Frames and modal/non-modal dialogs   
Jan 10, 2004 7:23 AM (reply 1 of 7)  (In reply to original post )

 
I have a swing application that has many frames and
dialogs. Is it possible to make a dialog modal for
some frames and non-modal for the others frames?

Thanks.

Its quite easy

first create your dialog

class Error_Dialog extends JDialog
//standard error dialog for displaying error messages
{
etc etc etc
}

ok then use code like this in your frame for a modal dialog

Error_Dialog ErD =new Error_Dialog();
Erd.setModal(true);

and use code like this for a non modal

Error_Dialog ErD =new Error_Dialog();
Erd.setModal(false);

hope this helps a bit

Boris
 
miltonxp
Posts:4
Registered: 9/19/02
Re: Frames and modal/non-modal dialogs   
Jan 12, 2004 4:09 AM (reply 2 of 7)  (In reply to #1 )

 
Thanks, but my problem is that I need to display the frames at same time.
 
stipanov
Posts:46
Registered: 12/26/01
Re: Frames and modal/non-modal dialogs   
Jan 13, 2004 12:20 AM (reply 3 of 7)  (In reply to #2 )

 
Thanks, but my problem is that I need to display the
frames at same time.

i'm not sure i understand what you mean...
dialogs may hide underlying frames if you press alt+tab while a dialog has focus, but this occurs only if you created the dialog without a reference to the underlying (owner) frame (or dialog). if your dialog is created like this:
JDialog dialog = new JDialog(owner) ,
where "owner" is a JFrame or JDialog, then alt+tab will work fine.

i hope this helps...
 
Ares_Man
Posts:930
Registered: 9/18/03
Re: Frames and modal/non-modal dialogs   
Jan 13, 2004 11:40 AM (reply 4 of 7)  (In reply to #2 )

 
Thanks, but my problem is that I need to display the
frames at same time.

You can only make one frame modal, AFAIK (in any language I've known). If you need two modal frames, can you possibly combine their GUIs onto one frame?
 
bertszoghy
Posts:56
Registered: 6/12/01
Re: Frames and modal/non-modal dialogs   
Jan 22, 2004 6:34 AM (reply 5 of 7)  (In reply to original post )

 
Hello,

You could launch your non-modal dialog in a separate thread. Code your dialog as a separate class and launch it with a SwingWorker.

I just finished an Open-Source application that does this, "BabyTalk Web", a SWING desktop text-to-speech that uses JAXB and Java Web Services. Check out how DialogList is launched.

http://www.quadmore.com/babytalkweb/

Hope this helps,
Bert Szoghy
Quadmore Software Services
"Home of Java Rollout for Windows"
 
jjasper4
Posts:18
Registered: 1/3/01
Re: Frames and modal/non-modal dialogs   
Mar 6, 2004 6:12 PM (reply 6 of 7)  (In reply to original post )

 
Take a look at the following project on java.net https://jmodalwindow.dev.java.net/

It makes a window or frame modal to parent frame only.

Just add funtionality to add more owners to the modal window/frame to block and unblock more 'parent frames'.
 
jjasper4
Posts:18
Registered: 1/3/01
Re: Frames and modal/non-modal dialogs   
Mar 23, 2004 9:28 AM (reply 7 of 7)  (In reply to #6 )

 
Go to https://jmodalwindow.dev.java.net/ and download demo version 1.04.

Run the demo with: java -jar swingx_v0104_demo.jar

And choose option 'Open a modal window that also blocks second demo frame.'

This should demonstrate the functionality that you're looking for.
 
This topic has 7 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 62
  • Guests : 141

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums