package net.xoetrope.xui.test;
import java.awt.Button;
import java.awt.Component;
import java.awt.Frame;
import junit.framework.TestCase;
import net.xoetrope.awt.XApplet;
import net.xoetrope.awt.XLabel;
import net.xoetrope.xui.XPage;
import net.xoetrope.xui.XProject;
import net.xoetrope.xui.XProjectManager;
import net.xoetrope.xui.style.XStyleFactory;
/**
* Title: Xui
* Description:
* Copyright: Copyright (c) Xoetrope Ltd., 1998-2003
* Company: Xoetrope Ltd.
* @author Xoetrope Ltd.
* @version 1.0
*/
public class TestXPanel extends TestCase
{
private XProject project;
public TestXPanel()
{
XApplet applet = new XApplet();
project = XProjectManager.getCurrentProject( applet );
}
public static void main ( String args[] )
{
TestXPanel testpanel = new TestXPanel();
testpanel.addComponents();
}
public void testCtor()
{
Frame testFrame = new Frame("Xui Test");
Component pnl = addComponents();
testFrame.add( pnl );
testFrame.setSize( 800, 600 );
testFrame.show();
try {
Thread.currentThread().sleep( 400 );
}
catch ( Exception e ){};
testFrame.hide();
}
private Component addComponents()
{
// XStyleManager style = TestStyles.getStyles();
XStyleFactory compfactory = null;
try {
compfactory = new XStyleFactory( project, "net.xoetrope.xui" );
}
catch ( Exception ex ) {
ex.printStackTrace();
}
Component xpanel = (Component)compfactory.addComponent( XPage.PANEL, 0, 0, 800, 600, null, "base/grey" );
Component xpanelc1 = (Component)compfactory.addComponent( XPage.PANEL, 10, 10, 160, 100, null, null );
Component xpanelc2 = (Component)compfactory.addComponent( XPage.PANEL, 10, 160, 360, 160, null, null );
/* First child panel */
compfactory.setParentComponent(xpanelc1);
XLabel lbl1 = (XLabel)compfactory.addComponent( XPage.LABEL, 10, 2, 80, 25, "test 1", null );
XLabel lbl2 = (XLabel)compfactory.addComponent( XPage.LABEL, 10, 30, 80, 25, "test 2", null );
/* Second child panel */
compfactory.setParentComponent(xpanelc2);
XLabel lbl3 = (XLabel)compfactory.addComponent( XPage.LABEL, 10, 2, 120, 50, "this is a piece of wrapping text", "bold" );
XLabel lbl4 = (XLabel)compfactory.addComponent( XPage.LABEL, 10, 90, 120, 20, "test 4", "bold" );
/* Add a generic component */
Button b = (Button)compfactory.addComponent( XPage.BUTTON, 120, 70, 150, 35, null );
b.setActionCommand("calculate");
b.setLabel("Test button");
b = (Button)compfactory.addComponent( XPage.BUTTON, 120, 110, 150, 35, null );
b.setLabel("Click me!!!");
return xpanel;
}
}