/*
 * Copyright (c) 2002-2007 TeamDev Ltd. All rights reserved.
 *
 * Use is subject to license terms.
 *
 * The complete licence text can be found at
 * http://www.jniwrapper.com/pages/macpack/license
 */
package com.jniwrapper.macosx.samples.demo;

import com.jniwrapper.samples.shell.components.HTMLText;
import com.jniwrapper.samples.shell.components.LazyPanel;
import com.jniwrapper.macosx.samples.TransparentNativePanel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author Vadim Steshenko
 */
public class NativePanelSample extends LazyPanel implements ActionListener
{
    private JLabel lblAdvisoryText;
    private JButton btnShowWindow;

    public NativePanelSample(Window parent)
    {
        super(parent);
    }

    public void initialize() throws Exception
    {
        lblAdvisoryText = new HTMLText("This sample demonstrates Native Panel.");
        btnShowWindow = new JButton("Show Panel");

        setLayout(new GridBagLayout());

        add(lblAdvisoryText, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));
        add(btnShowWindow, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(20, 0, 0, 0), 0, 0));
        add(new JPanel(), new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
                GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

        btnShowWindow.addActionListener(this);

        super.initialize();
    }

    public void actionPerformed(ActionEvent e)
    {
        TransparentNativePanel window = new TransparentNativePanel();
        window.run();
    }
}