Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does java.awt.dialog achieve modality?

I want to understand how java.awt.Dialog achieves modality (blocking other windows)?

Yeah, I tried reading the code of java.awt.Dialog, but I am kind of getting lost in it. So I want to know briefly what they do. Do they disable all events of all other windows?

Thanks Prem

like image 759
prembhaskal Avatar asked Nov 30 '12 14:11

prembhaskal


People also ask

What is AWT dialog in Java?

The Dialog control represents a top level window with a border and a title used to take some form of input from the user. It inherits the Window class. Unlike Frame, it doesn't have maximize and minimize buttons.

What are modes of dialog in Java?

There are two basic types of dialogs: modal and modeless. Modal dialogs block input to other top-level windows. Modeless dialogs allow input to other windows. An open file dialog is a good example of a modal dialog.

What creates a window dialog box in Java?

The showMessageDialog method creates a basic one-button dialog box. The showOptionDialog method, however, enables you to customize features like the number of buttons, the words on the buttons, and even allows you to ask for input in your dialog box. Notice that line 1 in the code above imports the Swing package.


1 Answers

Its system dependent. On windows the main event loop is modified. You are most of the time better off opening a dialog non-modal and lock the underlying window manually (e.g. set a glasspane to the rootpane and disable it, or block all events setting a custom focus manager).

like image 188
R.Moeller Avatar answered Oct 19 '22 22:10

R.Moeller