Exemple d’utilisation de ‘Dialog.ModalityType.DOCUMENT_MODAL’ pour définir la modalité d’une boîte de dialogue

Author:


{filelink=847}


import java.awt.Dialog;
import java.awt.FlowLayout;

import javax.swing.JDialog;
import javax.swing.JFrame;

public class ModaleOuNon {
  public static void main(String[] args) {
    final JFrame principale = new JFrame("Frame Principale");
    principale.setLayout(new FlowLayout());
    principale.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    principale.setBounds(100, 100, 300, 200);
    principale.setVisible(true);
    JDialog dialog1 = new JDialog(principale, "Dialog1 - Dialogue non modale");
    dialog1.setBounds(200, 200, 300, 200);
    dialog1.setVisible(true);

    JDialog dialog2 = new JDialog(principale, "Dialog2 - Dialogue modale",
        Dialog.ModalityType.DOCUMENT_MODAL);
    dialog2.setBounds(300, 300, 300, 200);

    JDialog dialog3 = new JDialog(dialog2, "Dialog3 - dialogue non modale");
    dialog3.setBounds(400, 400, 300, 200);
    dialog3.setVisible(true);

    dialog2.setVisible(true);

  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *