- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 Articles
- 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 type of reaction happens when we burn salt and sugar?
- What happens when iron is heated?
- What happens when sugar is heated?
- What happens when Zinc reacts with Sodium hydroxide?
- What happens when nitrogen oxide reacts with rainwater?
- State what type of change happens when: Producing Bio-Gas from cow dung?
- What happens when silk cloth rubs with a glass rod?
- What happens when you mix a strong acid with gold ?
- What happens when garbage is not disposed of properly?
- What happens when electricity is passed through tap water
- What happens when nitric acid is added to eggshell?

Advertisements