【Java开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了Java开源代码-UIDialogContainer.java的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
package com.cownew.PIS.ui.base;
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.HeadlessException;
import java.awt.event.WindowEvent;
import javax.swing.JMenuBar;
import javax.swing.JToolBar;
import com.cownew.ctk.ui.swing.JCownewDialog;
public class UIDialogContainer extends JCownewDialog implements IUIContainer
{
private static final int HEIGHTSPACE = 100;
private UIPanel uiPanel;
public UIDialogContainer(Dialog owner,UIPanel uiPanel) throws HeadlessException
{
super(owner);
this.uiPanel = uiPanel;
initialize();
}
public UIDialogContainer(Frame owner,UIPanel uiPanel) throws HeadlessException
{
super(owner);
this.uiPanel = uiPanel;
initialize();
}
public UIDialogContainer(Dialog owner, boolean modal,UIPanel uiPanel)
throws HeadlessException
{
super(owner, modal);
this.uiPanel = uiPanel;
initialize();
}
public UIDialogContainer(Frame owner, boolean modal,UIPanel uiPanel)
throws HeadlessException
{
super(owner, modal);
this.uiPanel = uiPanel;
initialize();
}
protected void initialize()
{
JMenuBar mainMenuBar = uiPanel.getMainMenuBar();
if (mainMenuBar != null)
{
setJMenuBar(mainMenuBar);
}
getContentPane().setLayout(new BorderLayout());
JToolBar toolBar = uiPanel.getToolBar();
if (toolBar != null)
{
getContentPane().add(toolBar, BorderLayout.NORTH);
}
getContentPane().add(uiPanel, BorderLayout.CENTER);
Dimension uiSize = uiPanel.getSize();
Dimension contSize = new Dimension();
contSize.height = uiSize.height + HEIGHTSPACE;
contSize.width = uiSize.width;
setSize(contSize);
setTitle(uiPanel.getUITitle());
}
public UIPanel getUIPanel()
{
return uiPanel;
}
protected void onClosed(WindowEvent e)
{
super.onClosed(e);
uiPanel.onClose();
}
protected void onOpend(WindowEvent e)
{
super.onOpend(e);
uiPanel.onOpen();
}
}