我正在分析我的客户提出的问题。我们有一个 JFrame,里面有 6 个 JInternalFrames。如果任何一个 JInternalFrame 被最大化,并且如果我们从这个 JInternalFrame 打开另一个 JInternalFrame,那么新的 JInternalFrame 也将以最大化状态打开。同样,如果它处于恢复模式,则另一个 JInternalFrame 将在恢复模式下打开。我需要知道新打开的 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