package MapEditor;

import java.awt.*;
import java.awt.event.*;

public class Util
{
	public static void draw_rectangle(Graphics g, int x1, int y1, int x2, int y2)
	{
		int minx = x1 < x2 ? x1 : x2;
		int maxx = x1 > x2 ? x1 : x2;
		int miny = y1 < y2 ? y1 : y2;
		int maxy = y1 > y2 ? y1 : y2;
		g.drawRect(minx,miny,maxx-minx,maxy-miny);
	}

	public static void message_box(Frame owner, String title, String ... messages)
	{
		final Dialog dialog = new Dialog(owner, title, true);
		dialog.setLayout(new GridLayout(messages.length + 1, 0));
		for(String m: messages) dialog.add(new Label(m));
		Button okButton = new Button("OK");
		okButton.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				dialog.dispose();
			}
		});
		dialog.add(okButton);
		dialog.setLocationRelativeTo(null);		// centre the dialog on the screen
		dialog.pack();
		dialog.setVisible(true);
	}
}
