《j2ee开发全程实录》随书源码
源代码在线查看: uifactory.java
package com.cownew.PIS.ui.base;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;
import javax.swing.WindowConstants;
import com.cownew.ctk.common.ExceptionUtils;
public class UIFactory
{
private static UIPanel getUIPanel(String uiClassName)
{
UIPanel uiPanel;
try
{
uiPanel = (UIPanel) Class.forName(uiClassName).newInstance();
} catch (InstantiationException e)
{
throw ExceptionUtils.toRuntimeException(e);
} catch (IllegalAccessException e)
{
throw ExceptionUtils.toRuntimeException(e);
} catch (ClassNotFoundException e)
{
throw ExceptionUtils.toRuntimeException(e);
}
return uiPanel;
}
public static UIDialogContainer getUIDialogContainer(String uiClassName,
Window owner)
{
UIPanel uiPanel = getUIPanel(uiClassName);
UIDialogContainer cont = null;
if(owner instanceof Dialog)
{
cont = new UIDialogContainer((Dialog)owner, true,uiPanel);
}
else if(owner instanceof Frame)
{
cont = new UIDialogContainer((Frame)owner,true, uiPanel);
}
cont.setResizable(false);
return cont;
}
public static UIDialogContainer getUIDialogContainer(String uiClassName,
Window owner, boolean modal)
{
UIPanel uiPanel = getUIPanel(uiClassName);
UIDialogContainer cont = null;
if(owner instanceof Dialog)
{
cont = new UIDialogContainer((Dialog)owner,modal, uiPanel);
}
else if(owner instanceof Frame)
{
cont = new UIDialogContainer((Frame)owner,modal, uiPanel);
}
cont.setResizable(false);
return cont;
}
public static UIInternalFrameContainer getInternalFrameContainer(String uiClassName)
{
UIPanel uiPanel = getUIPanel(uiClassName);
UIInternalFrameContainer cont = new UIInternalFrameContainer(uiPanel);
cont.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
return cont;
}
}