analyseWriter/src/fenetres/msgBox.java

104 lines
2.4 KiB
Java
Raw Normal View History

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;
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();
private JButton okButton = new JButton();
2022-05-26 20:10:24 +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);
{
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");
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);
}
}
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-26 20:10:24 +02:00
}
public void close() {
dispose();
}
2022-05-26 20:10:24 +02:00
}