package de.javasoft.synthetica.democenter.examples.detailsdialog;

import java.awt.Component;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import de.javasoft.swing.DetailsDialog;

/**
 * A simple DetailsDialog application used to demonstrate and explain  
 * basic functionality.
 */
@SuppressWarnings("serial")
public class SimpleDetailsDialog extends JFrame
{  
  /**
   * Constructor for the main application.  
   */
  public SimpleDetailsDialog()
  {
    super("Simple DetailsDialog Demo");    
    setLayout(new FlowLayout());
    
    JButton button = new JButton("Open DetailsDialog");
    button.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent evt)
      {
//@highlight
        DetailsDialog.showDialog(SwingUtilities.getWindowAncestor((Component)evt.getSource()), 
            "My Information Dialog", 
            "This is the message within the DetailsDialog!", 
            "Details Area.\nDetails Area.\nDetails Area.\nDetails Area.\nDetails Area.\n", 
            DetailsDialog.INFO_TYPE);
//@/highlight
      }
    });
    add(button);
    
    //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setSize(320, 240);
    setLocationRelativeTo(null);        //center
    setVisible(true);
  }

  /**
   * Static main method for application startup. 
   */
  public static void main(String[] args)
  {
    EventQueue.invokeLater(new Runnable()
    {
      public void run()
      {
        try
        {
          UIManager.setLookAndFeel("de.javasoft.plaf.synthetica.SyntheticaStandardLookAndFeel");
          new SimpleDetailsDialog();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
    });
  }
}
