package ru.nsu.ccfit.bogush.client.view;

import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.ActionEvent;

public class AlertDialog extends JDialog {
	private static final Dimension SIZE = new Dimension(150, 80);
	private static final Border MARGIN_BORDER = BorderFactory.createEmptyBorder(10, 10, 10, 10);

	public AlertDialog(Frame owner, String title, String description) {
		super(owner, title, true);
		JPanel contentPanel = new JPanel();
		contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
		contentPanel.setBorder(MARGIN_BORDER);

		JLabel alertLabel = new JLabel(description);
		alertLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
		contentPanel.add(alertLabel);

		JButton alertButton = new JButton(new AbstractAction() {
			@Override
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		alertButton.setText("Ok");
		alertButton.setAlignmentX(Component.CENTER_ALIGNMENT);
		contentPanel.add(alertButton);

		this.setContentPane(contentPanel);
		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		this.setLocationRelativeTo(null);
		this.setSize(SIZE);
		this.setResizable(false);
		this.setVisible(true);
	}
}

@@ -252,16 +252,55 @@
 0, 80);%0A
+%09private static final int MARGIN = 10;%0A
 %09private
@@ -372,123 +372,450 @@
 der(
-10, 10, 10, 10);%0A%0A%09public AlertDialog(Frame owner, String title, String description) %7B%0A%09%09super(owner, title, true);
+MARGIN, MARGIN, MARGIN, MARGIN);%0A%09private static final String ALERT_LABEL_FORMAT_STRING =%0A%09%09%09%22%3Chtml%3E%22 +%0A%09%09%09%09%09%22%3Cbody WIDTH=%25d style='text-align:center'%3E%22 +%0A%09%09%09%09%09%09%09%22%25s%22 +%0A%09%09%09%09%09%22%3Cbody%3E%22 +%0A%09%09%09%22%3C/html%3E%22;%0A%0A%09public AlertDialog(Frame owner, String title, String description) %7B%0A%09%09super(owner, title, true);%0A%09%09this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);%0A%09%09this.setLocationRelativeTo(null);%0A%09%09this.setMinimumSize(SIZE);%0A%09%09this.setResizable(false);%0A
 %0A%09%09J
@@ -846,16 +846,34 @@
  JPanel(
+new BorderLayout()
 );%0A%09%09con
@@ -1015,16 +1015,78 @@
  JLabel(
+String.format(ALERT_LABEL_FORMAT_STRING, SIZE.width-MARGIN*2, 
 descript
@@ -1089,16 +1089,17 @@
 ription)
+)
 ;%0A%09%09aler
@@ -1177,16 +1177,37 @@
 ertLabel
+, BorderLayout.CENTER
 );%0A%0A%09%09JB
@@ -1464,16 +1464,36 @@
 rtButton
+, BorderLayout.SOUTH
 );%0A%0A%09%09th
@@ -1536,135 +1536,13 @@
 his.
-setDefaultCloseOperation(DISPOSE_ON_CLOSE);%0A%09%09this.setLocationRelativeTo(null);%0A%09%09this.setSize(SIZE);%0A%09%09this.setResizable(false
+pack(
 );%0A%09

Fix alert dialog view