我正在分析我的客户提出的问题。我们有一个JFrame,在里面我们有6个JInternalFrames。如果JInternalFrame中的任何一个最大化,并且如果我们从这个JInternalFrame打开另一个JInternalFrame,那么新的JInternalFrame也将以最大化状态打开。类似如果它处于还原模式,则另一个JInternallFrame将在还原模式下打开。我需要知道新的开放JInternalFrame如何确定父框架处于最大化或恢复模式。
感谢所有人的考虑。
public Object openEditor(String p_editorClassName) {
Object editorObject = null;
try {
// is this window already open
editorObject = m_editorList.get(p_editorClassName);
boolean isNewEditor = editorObject == null;
if (isNewEditor)
{
++m_openFrameCount;editorObject = createNewEditor(p_editorClassName);
m_editorList.put(p_editorClassName, editorObject);
}
int defaultWidth = editorObject instanceof IEditor ? ((IEditor)editorObject).getDefaultEditorWidth() : IDEConstants.DEFAULT_EDITOR_WIDTH;
int defaultHeight = editorObject instanceof IEditor ? ((IEditor)editorObject).getDefaultEditorHeight() : IDEConstants.DEFAULT_EDITOR_HEIGHT;
if (editorObject instanceof JInternalFrame)
{
JInternalFrame editorFrame = (JInternalFrame) editorObject;
if (isNewEditor)
{
((GenericEditor)editorFrame).setQFTestName(((JInternalFrame)editorObject).getTitle());
editorFrame.setSize(defaultWidth, defaultHeight);
editorFrame.setVisible(true);
addFrameToDesktop(editorFrame);
editorFrame.setLocation(XOFFSET * m_openFrameCount, YOFFSET * m_openFrameCount);
if (editorObject instanceof GenericEditor)
{
DecimalFormat df = new DecimalFormat("00");
String strCount = df.format(m_editorList.size());
String editorKey = EditorsIDEState.PROP_EDITOR + strCount;
((GenericEditor)editorObject).setState(getIDEState().getProps(), editorKey, p_editorClassName);
}
}
else
{
// Need to undo minimize here, otherwise it will return null for getParent() and will
// then re-add back into desktop below
//
if (editorFrame.isIcon())
{
editorFrame.setIcon(false);
}
// Check to see if we have ever been added to the desktop
//
if (editorFrame.getParent() == null)
{
addFrameToDesktop(editorFrame);
}
if (editorFrame.getWidth() < 1 && editorFrame.getHeight() < 1)
{
// width and height is not visible, so set the size back to the original
editorFrame.setSize(defaultWidth, defaultHeight);
}
else if (editorFrame.getWidth() < 1)
{
// width is not visible, so set the width back to the original
editorFrame.setSize(defaultWidth, editorFrame.getHeight());
}
else if (editorFrame.getHeight() < 1)
{
// height is not visible, so set the height back to the original
editorFrame.setSize(editorFrame.getWidth(), defaultHeight);
}
// is this window still visible
if (editorFrame.isClosed())
{
// to reopen an JInternalFrame, re-attach to container
editorFrame.setVisible(true);
editorFrame.setClosed(false);
addFrameToDesktop(editorFrame);
}
if (!editorFrame.isVisible())
{
editorFrame.setVisible(true);
}
}
editorFrame.setSelected(true);
editorFrame.moveToFront();
}
}
catch (Exception e)
{
e.printStackTrace();
}
return editorObject;
}
调试时我的IsMaximum为FALSE直到第二行,即editorFrame.setSelected(true);在此之后我将获得IsMaximum为TRUE