/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:set ts=4 sw=4 sts=4 et: */
package jp.oist.flint.form;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.UIManager;

public class MessageDialog extends JPanel {

    private final static int WIDTH  = 480;

    private final static int HEIGHT = 320;

    public static void showMessageDialog (Component parent, Object msg, Object detail, String title) {
        showMessageDialog(parent, msg, detail, title, JOptionPane.INFORMATION_MESSAGE, null, new Object[] {"CANCEL", "OK"});
    }

    public static void showMessageDialog (Component parent, Object msg, Object detail, String title, int messageType) {
        showMessageDialog(parent, msg, detail, title, messageType, null, new Object[]{"CANCEL", "OK"});
    }

    public static void showMessageDialog (Component parent, Object msg, Object detail, String title, int messageType, Icon icon) {
        showMessageDialog(parent, msg, detail, title, messageType, icon, new Object[]{"CANCEL", "OK"});
    }

    public static void showMessageDialog (Component parent, Object msg, Object detail, String title, int messageType, Icon icon, Object[] options) {
        MessageDialog me = new MessageDialog(msg, detail);
        JOptionPane optionPane = new JOptionPane(me, messageType, 
                JOptionPane.DEFAULT_OPTION, icon, options);

        if (parent != null)
            optionPane.setComponentOrientation(parent.getComponentOrientation());

        JDialog dialog = optionPane.createDialog(parent, title);
        dialog.pack();
        dialog.setResizable(true);

        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        dialog.setVisible(true);
    }

    private final String mMessage;

    private final String mDetail;

    private MessageDialog (Object message, Object detail) {
        super(new BorderLayout());

        mMessage = (message == null)? "" : message.toString();
        mDetail  = (detail == null)? "" : detail.toString();

        initComponents();
    }

    private void initComponents () {
        Dimension size = new Dimension(WIDTH, HEIGHT);
        setSize(size);
        setPreferredSize(size);
        setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
        setMinimumSize(size);

        JTextArea messageArea = new JTextArea(mMessage);
        messageArea.setBackground(UIManager.getColor("Panel.background"));
        messageArea.setEditable(false);

        JTextArea detailArea = new JTextArea(mDetail);
        detailArea.setEditable(false);

        JPanel messageField = new JPanel();
        messageField.setLayout(new FlowLayout(FlowLayout.LEADING));

        size = new Dimension(WIDTH, 80);
        messageArea.setSize(size);
        messageArea.setPreferredSize(size);
        messageArea.setMaximumSize(size);
        messageArea.setMinimumSize(size);

        messageField.setSize(size);
        messageField.setPreferredSize(size);
        messageField.setMaximumSize(size);
        messageField.setMinimumSize(size);

        messageField.add(messageArea);

        add(messageField, BorderLayout.NORTH);
        add(new JScrollPane(detailArea), BorderLayout.CENTER);
    }

}

@@ -192,63 +192,8 @@
 nt;%0A
-import java.awt.Dimension;%0Aimport java.awt.FlowLayout;%0A
 impo
@@ -241,16 +241,43 @@
 Dialog;%0A
+import javax.swing.JLabel;%0A
 import j
@@ -392,38 +392,8 @@
 rea;
-%0Aimport javax.swing.UIManager;
 %0A%0Apu
@@ -439,96 +439,8 @@
  %7B%0A%0A
-    private final static int WIDTH  = 480;%0A%0A    private final static int HEIGHT = 320;%0A%0A
     
@@ -2195,1032 +2195,172 @@
     
-Dimension size = new Dimension(WIDTH, HEIGHT);%0A        setSize(size);%0A        setPreferredSize(size);%0A        setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));%0A        setMinimumSize(size);%0A%0A        JTextArea messageArea = new JTextArea(mMessage);%0A        messageArea.setBackground(UIManager.getColor(%22Panel.background%22));%0A        messageArea.setEditable(false);%0A%0A        JTextArea detailArea = new JTextArea(mDetail);%0A        detailArea.setEditable(false);%0A%0A        JPanel messageField = new JPanel();%0A        messageField.setLayout(new FlowLayout(FlowLayout.LEADING));%0A%0A        size = new Dimension(WIDTH, 80);%0A        messageArea.setSize(size);%0A        messageArea.setPreferredSize(size);%0A        messageArea.setMaximumSize(size);%0A        messageArea.setMinimumSize(size);%0A%0A        messageField.setSize(size);%0A        messageField.setPreferredSize(size);%0A        messageField.setMaximumSize(size);%0A        messageField.setMinimumSize(size);%0A%0A        messageField.add(messageArea);%0A%0A        add(messageField
+JLabel messageLabel = new JLabel(mMessage);%0A%0A        JTextArea detailArea = new JTextArea(mDetail);%0A        detailArea.setEditable(false);%0A%0A        add(messageLabel
 , Bo

fix nonsense on the layout