/*
 * Copyright (c) 2000-2009 TeamDev Ltd. All rights reserved.
 * TeamDev PROPRIETARY and CONFIDENTIAL.
 * Use is subject to license terms.
 */
package com.jniwrapper.win32.samples.demo;

import com.jniwrapper.samples.shell.components.HTMLText;
import com.jniwrapper.samples.shell.components.LazyPanel;
import com.jniwrapper.win32.samples.TransparentNativeWindow;
import com.jniwrapper.win32.ui.Wnd;

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

/**
 @author Serge Piletsky
 */
public class NativeWindowSample extends LazyPanel implements ActionListener
{
    private JLabel lblAdvisoryText;
    private JButton btnShowWindow;

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

    public void initialize() throws Exception
    {
        lblAdvisoryText = new HTMLText("This sample demonstrates Native Dialog created with WinPack.");
        btnShowWindow = new JButton("Show Native Dialog");
        setLayout(new GridBagLayout());

        add(lblAdvisoryText, new GridBagConstraints(00110.00.0
                , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10101010)00));

        add(btnShowWindow, new GridBagConstraints(02110.00.0,
                GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(20000)00));

        add(new JPanel()new GridBagConstraints(03111.01.0
                , GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0000)00));

        btnShowWindow.addActionListener(this);

        super.initialize();
    }

    public void actionPerformed(ActionEvent e)
    {
        Wnd wnd = Wnd.getDesktopWindow();
        int WIDTH = 400;
        int HEIGHT = 200;
        long X = (wnd.getSize().getCx() - WIDTH2;
        long Y = (wnd.getSize().getCy() - HEIGHT2;
        TransparentNativeWindow window = new TransparentNativeWindow(X, Y, WIDTH, HEIGHT);
        window.run();
    }
}