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

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;

import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;

import org.jdesktop.swingx.JXTitledSeparator;

/**
 * A simple TitledSeparator application used to demonstrate and explain  
 * basic functionality.
 */
@SuppressWarnings("serial")
public class SimpleTitledSeparator extends JFrame
{
  /**
   * Constructor for the main application.  
   */
  public SimpleTitledSeparator()
  {
    super("Simple TitledSeparator Demo");    
    
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    
//@highlight
    //create a plain separator
    JXTitledSeparator sep = new JXTitledSeparator();
    sep.setTitle("Customer Info");
    panel.add(sep);

    //create a separator with an icon
    sep = new JXTitledSeparator();
    sep.setTitle("Customer Info");
    sep.setIcon(new ImageIcon(getClass().getResource("/resources/icons/tip.png")));
    panel.add(sep);

    //create a separator with an icon to the right of the title, center justified
    sep = new JXTitledSeparator();
    sep.setTitle("Customized Color and Font");
    sep.setIcon(new ImageIcon(getClass().getResource("/resources/icons/tip.png")));
    sep.setHorizontalAlignment(SwingConstants.CENTER);
    sep.setHorizontalTextPosition(SwingConstants.LEADING);
    sep.setForeground(Color.RED);
    sep.setFont(new Font("Dialog", Font.BOLD, 14));
    panel.add(sep);
//@/highlight
    
    add(panel);
    //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setSize(400, 300);
    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 SimpleTitledSeparator();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
    });
  }

}
