Results 1 to 6 of 6

Thread: In Java, how to use Modality in Dialogs?

  1. #1
    Join Date
    Aug 2006
    Posts
    222

    In Java, how to use Modality in Dialogs?

    Hi everyone,
    I have recently started with the Java, before that I have done C++ and HTML programming languages. I have created a dialog box in my application in Java. I am told to use the modality into that.!! But I don't have any idea about using the modality. Really speaking I don't know the term modality. So can anyone explain me what is modality and how to use Modality in Dialogs.?? Expecting help from your side sooner.!!
    Just a reply to say thank you for these links and posts I have a lot to read and learn now!



  2. #2
    Join Date
    Nov 2008
    Posts
    1,192

    Re: In Java, how to use Modality in Dialogs?

    hi 'Bigga Lexx', I think that you should first get the concept of the dialog box that are used in Java. Dialog box are the pop-up windows with the title and border that requires an input from the users. There are two types of dialog boxes :
    Modal dialog box - Many times you have observed that when the dialog box pop ups, you cannot do the other things but you have to input something in that dialog box first. Such type of dialog box are called as modal dialog box. In simple words you can say that it blocks user input to all other windows.
    Modeless dialog box - In this type, you can do interact with the other windows even if this dialog box is opened.

  3. #3
    Join Date
    Mar 2008
    Posts
    349

    Re: In Java, how to use Modality in Dialogs?

    You should also have a knowledge about the modality types that are supported in Java versions. I am specifying some of the types that are supported by the Java SE 6 :
    • Modeless type - This is one type of the dialog box. This dialog box does not block any other window while it is visible.
    • Application-modal type - An application-modal dialog box blocks all windows from the same application. But it has some different feature from the modal dialog box which also blocks the other windows, but the different feature is that this dialog box except windows from its child hierarchy.
    • Document-modal type - A Document-modal type is very much similar to the application modal type. But in this context, a document is a hierarchy of windows that share a common ancestor which is the closest ancestor window without an owner. This is called as the document root.

  4. #4
    Join Date
    Jul 2006
    Posts
    289

    Re: In Java, how to use Modality in Dialogs?

    I am providing you with the code snippets that may help you in creating the modality in dialogs. In the following sample of coding I have shown you how to create dialog boxes of different modality types :
    Code:
    f1 = new JFrame("Guide A (parent frame)");
    
    ...
    
    d2 = new JDialog(f1);
    ...
    	
    d3 = new JDialog(d2, "", Dialog.ModalityType.DOCUMENT_MODAL);
    
    ...
    
    f4 = new JFrame("Guide B (parent frame)");
    
    ...
    
    d5 = new JDialog(f4);
    
    ...
    
    d6 = new JDialog(d5, "", Dialog.ModalityType.DOCUMENT_MODAL);
    	
    ...
    Signatures reduce available bandwidth

  5. #5
    Join Date
    Aug 2006
    Posts
    235

    Re: In Java, how to use Modality in Dialogs?

    After using the coding for creating the dialog boxes, you can use the following codes for completion of that dialog boxes. The codes that is mentioned by the 'Viensterrr', is just to create the dialog boxes. You can use the following code for doing the further coding into that :
    Code:
    JButton b8 = new JButton("How was that.!?");
    b8.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            JOptionPane.showConfirmationDialog(null,
                                               "Did you liked the Guide?",
                                               "Question (application-modal dialog)", 
                                               JOptionPane.Yes_NO_OPTION,
                                               JOptionPane.QUESTION_MESSAGE); 
        }
    })
    3.2 (northwood)
    2gig ram
    ATI AIW X800xt 256mb
    Gigabyte GA-8knxp 875p Chipset
    Optiwrite 8X DVD Burner
    Win XP PRO Sp2 (Works Perfectly)
    2 SATA Raptor 74gig Raid 0
    2 7200 IDE 320gig HD

  6. #6
    Join Date
    Jul 2006
    Posts
    286

    Re: In Java, how to use Modality in Dialogs?

    For creating the dialog boxes you need some constructors. That constructors should be of JDialog class because the JDialog class constructors enable you to create dialog boxes of various modality types. The following are some types of JDialog class constructors :
    • JDialog(Dialog owner) - This type of the constructor creates a modeless dialog box with the specified Dialog owner but without a title.
    • JDialog(Dialog owner, boolean modal) - This constructor is used for creating a dialog box with the specified Dialog owner and modality.
    • JDialog(Dialog owner, String title) - This constructor creates a modeless dialog box with the specified Dialog owner and title.
    • JDialog(Frame owner) - This constructor creates a modeless dialog box without a title with the specified Frame owner.
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

Similar Threads

  1. Replies: 4
    Last Post: 04-09-2013, 11:04 PM
  2. UAC dialogs pop up under other windows
    By Delgado in forum Operating Systems
    Replies: 5
    Last Post: 18-08-2010, 04:46 AM
  3. Disable the Sticky Keys Popup Dialogs
    By ADJATAY in forum Customize Desktop
    Replies: 3
    Last Post: 19-05-2009, 11:16 PM
  4. How to Customize dialogs in visual studio
    By Sachit in forum Software Development
    Replies: 3
    Last Post: 06-03-2009, 01:28 PM
  5. Standard file dialogs (open, save) cause Office 2007 to hang
    By neil.steiner in forum MS Office Support
    Replies: 4
    Last Post: 07-12-2008, 06:31 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,401,383.69724 seconds with 16 queries