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

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

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

import de.javasoft.swing.AboutDialog;

/**
 * A simple AboutDialog application used to demonstrate and explain  
 * basic functionality.
 */
@SuppressWarnings("serial")
public class SimpleAboutDialog extends JFrame
{  
  /**
   * Constructor for the main application.  
   */
  public SimpleAboutDialog()
  {
    super("Simple AboutDialog Demo");    
    setLayout(new FlowLayout());
    
    JButton button = new JButton("Open AboutDialog");
    button.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent evt)
      {
//@highlight
        try
        {
          AboutDialog.showDialog(SwingUtilities.getWindowAncestor((Component)evt.getSource()), 
              null, 
              "About this application.", 
              "My About Text");
          /*AboutDialog dialog = new AboutDialog(SwingUtilities.getWindowAncestor((Component)evt.getSource()), true);
          dialog.setTitle("About Title");
          dialog.setDescription("About this application.");
          dialog.setAboutText("My About Text");
          dialog.setDialogSize(new Dimension(800, 600));
          dialog.showDialog();*/
        }
        catch (IOException e)
        {
          e.printStackTrace();
        }
//@/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 SimpleAboutDialog();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
    });
  }
}
