/*
 * Swogl - Swing meets OpenGL
 * 
 * Copyright 2007-2011 Marco Hutter - http://swogl.javagl.de
 */

package de.javagl.swogl.samples;

import java.awt.Dimension;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.SwingUtilities;

import de.javagl.swogl.SwoglApplication;
import de.javagl.swogl.SwoglApplications;
import de.javagl.swogl.SwoglComponent;
import de.javagl.swogl.SwoglComponents;
import de.javagl.swogl.SwoglContainer;

/**
 * This is a minimal Swogl application, just showing a single 
 * SwoglComponent
 */
public class SwoglApplicationSample
{
    /**
     * Entry point of this sample
     * 
     * @param args Not used
     */
    public static void main(String[] args)
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                // Create a SwoglApplication
                SwoglApplication swoglApplication = 
                    SwoglApplications.createSwoglApplication();

                // Create a SwoglContainer for the SwoglApplication
                SwoglContainer swoglContainer = 
                    SwoglContainer.create(swoglApplication);

                // Create a demo Swing component
                JComponent component = new JScrollPane(new JTree());
                component.setPreferredSize(new Dimension(150, 100));

                // Create a SwoglComponent that contains the Swing component
                SwoglComponent swoglComponent = 
                    SwoglComponents.create(component);
                
                // Add the SwoglComponent to the SwoglContainer
                swoglContainer.add(swoglComponent);
                
                // Create a frame that contains the main component 
                // from the SwoglContainer
                JFrame frame = new JFrame("Swogl");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.getContentPane().add(swoglContainer.getMainComponent());
                frame.setSize(600,600);
                frame.setVisible(true);
            }
        });
    }
}

