package grid;

import nextapp.echo.app.ApplicationInstance;
import nextapp.echo.app.ContentPane;
import nextapp.echo.app.Label;
import nextapp.echo.app.Window;
import nextapp.echo.app.*;


import nextapp.echo.app.event.ActionListener;
import nextapp.echo.app.event.ActionEvent;

public class GridApp extends ApplicationInstance {
		
	private	Grid defGrid;
	private	ContentPane contentPane;
	private	WindowPane windowPane;

    public Window init() {
        Window window = new Window();
		window.setTitle("Grid Example");
		defGrid=new Grid();
		defGrid.setBorder(new Border(2,Color.BLUE,Border.STYLE_SOLID));
		defGrid.add(new Label("Item1"));
		defGrid.add(new Label("Item2"));
		contentPane = new ContentPane();
		windowPane = new WindowPane();
        Button def=new Button("Add a default grid of 2 ");
		def.setBorder(new Border(2,Color.BLUE,Border.STYLE_SOLID));
		contentPane.add(def);		
		def.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e)
            {
               contentPane.add(windowPane);
			   windowPane.setTitle("Default Grid");
			   windowPane.add(defGrid);
            }
        });		
		window.setContent(contentPane);
        return window;
    }	
} 