Files
BUT2/DEV/DEV3.1/TP02/Part2/CloseVerificationWindow.java
2025-09-26 11:16:47 +02:00

38 lines
1.2 KiB
Java

import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class CloseVerificationWindow extends JDialog {
public CloseVerificationWindow(ImageWindow parent) {
super(parent, true);
this.setSize(parent.getWidth() / 3, parent.getHeight() / 3);
this.setLocationRelativeTo(parent);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
this.setLayout(new GridLayout(2, 1));
JLabel text = new JLabel("Are you sure you want to close the window?");
text.setVerticalAlignment(JLabel.CENTER);
text.setHorizontalAlignment(JLabel.CENTER);
this.add(text);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
JButton approveButton = new JButton("Yes");
approveButton.addActionListener(new ApprovedButtonPressedEvent(this));
panel.add(approveButton, BorderLayout.WEST);
JButton cancelButton = new JButton("No");
cancelButton.addActionListener(new CancelButtonPressedEvent(this));
panel.add(cancelButton, BorderLayout.EAST);
this.add(panel);
}
}