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

import java.awt.EventQueue;
import java.util.Properties;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.UIManager;

import org.jdesktop.swingx.JXTipOfTheDay;
import org.jdesktop.swingx.tips.TipLoader;
import org.jdesktop.swingx.tips.TipOfTheDayModel;

/**
 * A simple TipOfTheDay application used to demonstrate and explain  
 * basic functionality.
 */
@SuppressWarnings("serial")
public class SimpleTipOfTheDay extends JFrame
{  
  /**
   * Constructor for the main application.  
   */
  public SimpleTipOfTheDay()
  {
    super("Simple TipOfTheDay Demo");    
    add(new JLabel("Main Application"));
    //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setSize(640, 480);
    setLocationRelativeTo(null);        //center
    setVisible(true);    
    
//@highlight
    showTipOfTheDay();
//@/highlight
  }

  /**
   * Display tip of the day dialog.  
   */
  private void showTipOfTheDay()
  {
//@highlight
    Properties tips = new Properties();
    tips.put("tip.1.description", "<html>'Tip of the Day' supports simple <b>HTML</b> tags.</html>");
    tips.put("tip.2.description", "SyntheticaAddons provides additional Swing components optimized for the use with Synthetica.");

    TipOfTheDayModel model = TipLoader.load(tips);
    JXTipOfTheDay totd = new JXTipOfTheDay(model);         
    totd.showDialog(null);
//@/highlight
  }

  /**
   * 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 SimpleTipOfTheDay();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
    });
  }
}
