2022-06-19 21:01:30 +02:00
|
|
|
package fenetres;
|
2022-05-26 20:10:24 +02:00
|
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
import java.awt.FlowLayout;
|
|
|
|
|
|
|
|
import javax.swing.JButton;
|
|
|
|
import javax.swing.JDialog;
|
2022-06-01 21:38:37 +02:00
|
|
|
import javax.swing.JFrame;
|
2022-05-26 20:10:24 +02:00
|
|
|
import javax.swing.JPanel;
|
|
|
|
import javax.swing.border.EmptyBorder;
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
import java.awt.event.ActionListener;
|
2022-05-28 19:13:25 +02:00
|
|
|
import java.awt.event.WindowAdapter;
|
|
|
|
import java.awt.event.WindowEvent;
|
2022-05-26 20:10:24 +02:00
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
2022-06-01 21:38:37 +02:00
|
|
|
public class msgBox extends JFrame {
|
2022-05-26 20:10:24 +02:00
|
|
|
|
2022-05-26 20:15:20 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = 1L;
|
2022-05-26 20:10:24 +02:00
|
|
|
private final JPanel contentPanel = new JPanel();
|
|
|
|
|
2022-05-28 19:13:25 +02:00
|
|
|
private JButton okButton = new JButton();
|
2022-05-26 20:10:24 +02:00
|
|
|
|
2022-05-28 19:13:25 +02:00
|
|
|
|
2022-05-26 20:10:24 +02:00
|
|
|
/**
|
|
|
|
* Create the dialog.
|
|
|
|
*/
|
|
|
|
public msgBox(String message, Boolean AfficheOK, Boolean AfficheCancel, String Titre) {
|
|
|
|
setTitle(Titre);
|
|
|
|
JLabel lblMessage = new JLabel(message);
|
|
|
|
setBounds(100, 100, 437, 180);
|
|
|
|
getContentPane().setLayout(new BorderLayout());
|
|
|
|
contentPanel.setLayout(new FlowLayout());
|
|
|
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
|
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
|
|
|
{
|
|
|
|
contentPanel.add(lblMessage);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
JPanel buttonPane = new JPanel();
|
|
|
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
|
|
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
|
|
|
{
|
2022-05-28 19:13:25 +02:00
|
|
|
okButton = new JButton("OK");
|
2022-05-26 20:10:24 +02:00
|
|
|
okButton.addActionListener(new ActionListener() {
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
dispose();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
okButton.setActionCommand("OK");
|
|
|
|
okButton.setVisible(AfficheOK);
|
|
|
|
buttonPane.add(okButton);
|
|
|
|
getRootPane().setDefaultButton(okButton);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
JButton cancelButton = new JButton("Cancel");
|
2022-05-28 19:13:25 +02:00
|
|
|
cancelButton.addActionListener(new ActionListener() {
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
dispose();
|
|
|
|
}
|
|
|
|
});
|
2022-05-26 20:10:24 +02:00
|
|
|
cancelButton.setActionCommand("Cancel");
|
|
|
|
buttonPane.add(cancelButton);
|
|
|
|
cancelButton.setVisible(AfficheCancel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-28 19:13:25 +02:00
|
|
|
|
|
|
|
addWindowListener(new WindowAdapter()
|
|
|
|
{
|
|
|
|
public void windowClosed(WindowEvent e)
|
|
|
|
{
|
|
|
|
System.out.println("jdialog window closed event received");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void windowClosing(WindowEvent e)
|
|
|
|
{
|
|
|
|
System.out.println("jdialog window closing event received");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-26 20:10:24 +02:00
|
|
|
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
2022-05-28 19:13:25 +02:00
|
|
|
|
2022-05-26 20:10:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void close() {
|
|
|
|
dispose();
|
|
|
|
}
|
|
|
|
|
2022-05-28 19:13:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-26 20:10:24 +02:00
|
|
|
}
|