

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What happens when JDialog is set with Modality type APPLICATION_MODAL
The JDialog Modality type APPLICATION_MODAL blocks all top-level windows and it has restrictions. The following is an example to set JDialog with Modality type APPLICATION_MODAL:
Example
import java.awt.Cursor; import java.awt.Dialog.ModalityType; import java.awt.Dimension; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(new Dimension(600, 400)); JDialog dialog = new JDialog(frame, "New",ModalityType.APPLICATION_MODAL); dialog.setSize(300, 300); frame.add(new JButton(new AbstractAction("Click to generate") { @Override public void actionPerformed(ActionEvent e) { frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); dialog.setVisible(true); } })); frame.setVisible(true); } }
Output
Now, click on it to generate a new Dailog. You cannot close both the dialog at any time since it isn’t Modeless. You have to first close the new Dialog, the you will be able to close the first:
- Related Questions & Answers
- What happens when JDialog is set with Modality type MODELESS in Java
- What happens when we type a URL?
- What happens when length of object is set to 0 - JavaScript?
- What happens when buffer is set to a value "none" in JSP?
- What Happens When You Quit Smoking?
- What happens when serum calcium level drops?
- What happens when you control your mind?
- What happens when a String is accepted or rejected by NPDA?
- What happens when a function is called before its declaration in C?
- What happens when a negative value is inserted to UNSIGNED column in MySQL?
- What happens when MySQL encounters an out-of-range date?
- What happens with the trigger when we will drop the table having that trigger?
- What happens when a subclass object is assigned to a superclass object in Java?
- What happens when you do not declare a variable in JavaScript?
- What happens when you declare a method/constructor final in Java?
Advertisements