package demo;

import com.uvigo.mhp.*;
import java.awt.*;
import java.awt.event.*;
import org.havi.ui.*;

public class frontpage extends FrontEnd
{
    public frontpage()
    {
        try
        {
            initComponents();
            courseDelegate.setPage(this);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        mainContextManager = new com.uvigo.mhp.ContextManager();
        courseDelegate = new com.uvigo.mhp.CourseDelegate();
        hInternalFrame2 = new com.uvigo.mhp.ui.HInternalFrame();
        hInternalFrame1 = new com.uvigo.mhp.ui.HInternalFrame();
        hMenu1 = new com.uvigo.mhp.ui.HMenu();
        hInternalFrame3 = new com.uvigo.mhp.ui.HInternalFrame();
        hButton1 = new com.uvigo.mhp.ui.HButton();
        hButton2 = new com.uvigo.mhp.ui.HButton();
        hButton3 = new com.uvigo.mhp.ui.HButton();
        hButton4 = new com.uvigo.mhp.ui.HButton();
        hScrollPane1 = new com.uvigo.mhp.ui.HScrollPane();

        hInternalFrame2.setLayout(new java.awt.GridLayout(1, 1));

        hInternalFrame2.setBackground(java.awt.Color.magenta);
        hInternalFrame2.setName("panel");
        hInternalFrame2.setOpaque(true);

        setLayout(null);

        setBackgroundImageURL("file:/c:/teleco/mhp/fondo1.gif");
        setMainPanel(hScrollPane1);
        hInternalFrame1.setLayout(new java.awt.GridLayout(1, 1));

        hInternalFrame1.setBackground(java.awt.Color.black);
        hInternalFrame1.setFont(new java.awt.Font("Blippo Light SF", 1, 14));
        hInternalFrame1.setForeground(java.awt.Color.orange);
        hInternalFrame1.setLabel("Menu");
        hMenu1.setBackground(new java.awt.Color(204, 255, 204));
        hMenu1.setBackgroundMode(org.havi.ui.HVisible.BACKGROUND_FILL);
        hMenu1.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP);
        hMenu1.setName("menu");
        hMenu1.addContextListener(new com.uvigo.mhp.ContextListener() {
            public void contextChanged(com.uvigo.mhp.ContextEvent param0) {
                hMenu1ContextChanged(param0);
            }
            public void subcontextEntered(com.uvigo.mhp.ContextEvent param0) {
            }
        });

        hInternalFrame1.add(hMenu1);

        add(hInternalFrame1);
        hInternalFrame1.setBounds(10, 10, 440, 60);

        hInternalFrame3.setLayout(new java.awt.GridLayout(0, 4));

        hInternalFrame3.setBackground(java.awt.Color.magenta);
        hInternalFrame3.setOpaque(true);
        hButton1.setContentFile("file:/c:/teleco/demo/botones/first.xml");
        hButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hButton1ActionPerformed(evt);
            }
        });

        hInternalFrame3.add(hButton1);

        hButton2.setContentFile("file:/c:/teleco/demo/botones/previous.xml");
        hButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hButton2ActionPerformed(evt);
            }
        });

        hInternalFrame3.add(hButton2);

        hButton3.setContentFile("file:/c:/teleco/demo/botones/next.xml");
        hButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hButton3ActionPerformed(evt);
            }
        });

        hInternalFrame3.add(hButton3);

        hButton4.setContentFile("file:/c:/teleco/demo/botones/last.xml");
        hButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hButton4ActionPerformed(evt);
            }
        });

        hInternalFrame3.add(hButton4);

        add(hInternalFrame3);
        hInternalFrame3.setBounds(460, 10, 250, 60);

        hScrollPane1.setBackground(java.awt.Color.magenta);
        hScrollPane1.setDoubleBuffered(true);
        hScrollPane1.setOpaque(true);
        add(hScrollPane1);
        hScrollPane1.setBounds(30, 80, 660, 480);

    }//GEN-END:initComponents

    private void hButton4ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_hButton4ActionPerformed
    {//GEN-HEADEREND:event_hButton4ActionPerformed
        courseDelegate.gotoLastPage();
    }//GEN-LAST:event_hButton4ActionPerformed

    private void hButton3ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_hButton3ActionPerformed
    {//GEN-HEADEREND:event_hButton3ActionPerformed
        courseDelegate.gotoNextPage();
    }//GEN-LAST:event_hButton3ActionPerformed

    private void hButton2ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_hButton2ActionPerformed
    {//GEN-HEADEREND:event_hButton2ActionPerformed
        courseDelegate.gotoPreviousPage();
    }//GEN-LAST:event_hButton2ActionPerformed

    private void hButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_hButton1ActionPerformed
    {//GEN-HEADEREND:event_hButton1ActionPerformed
        courseDelegate.gotoFirstPage();
    }//GEN-LAST:event_hButton1ActionPerformed

    private void hMenu1ContextChanged(com.uvigo.mhp.ContextEvent evt)//GEN-FIRST:event_hMenu1ContextChanged
    {//GEN-HEADEREND:event_hMenu1ContextChanged
        courseDelegate.gotoPage(hMenu1.getSelectedIndex());
    }//GEN-LAST:event_hMenu1ContextChanged
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.uvigo.mhp.CourseDelegate courseDelegate;
    private com.uvigo.mhp.ui.HButton hButton1;
    private com.uvigo.mhp.ui.HButton hButton2;
    private com.uvigo.mhp.ui.HButton hButton3;
    private com.uvigo.mhp.ui.HButton hButton4;
    private com.uvigo.mhp.ui.HInternalFrame hInternalFrame1;
    private com.uvigo.mhp.ui.HInternalFrame hInternalFrame2;
    private com.uvigo.mhp.ui.HInternalFrame hInternalFrame3;
    private com.uvigo.mhp.ui.HMenu hMenu1;
    private com.uvigo.mhp.ui.HScrollPane hScrollPane1;
    private com.uvigo.mhp.ContextManager mainContextManager;
    // End of variables declaration//GEN-END:variables
    
    
    public static void main(String[] args)
    {
        HSceneFactory hsFactory = HSceneFactory.getInstance();
        HScene scene = hsFactory.getBestScene(new HSceneTemplate());
        scene.setLayout(new BorderLayout());
        
        scene.add(new frontpage());
        
        scene.addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                System.exit(0);
            }
        }
        );
        scene.setVisible(true);
        scene.validate();
    }
}
