여러 개의 JIF를 여는 응용 프로그램이 있지만 JIF의 단일 인스턴스 만 만들고 싶습니다. 그래서이 함수를 사용하여 확인하고 키를 누른 후에 JIF를 닫습니다 (JDesktopPane.getSelectedFrame() .dispose()). 그러나 2 ~ 3 회 연속 폐기하면 새로운 JIF가 생성되지 않습니다. 내가 여기서 잘못하고있는거야?JInternalFrame의 단일 인스턴스를 유지 관리 하시겠습니까?
public static void setInternalFrame(final JInternalFrame internalFrame) {
log.debug("CurActiveInternalFrame " + ShoppyPOSApp.getCurrentActiveInternalFrame(), null);
log.debug("Incoming internalFrame " + internalFrame, null);
boolean isFrameFound = false;
try {
// Have a check whether the DesktopPane contains the internal Frame
// If yes bring it to front and set the focus
for (int i = 0; i < ShoppyPOSApp.frame.mainDesktopPane.getAllFrames().length; i++) {
if (ShoppyPOSApp.frame.mainDesktopPane.getAllFrames()[i].getClass() == internalFrame.getClass()) {
isFrameFound = true;
}
}
if (!isFrameFound) {
internalFrame.setVisible(true);
internalFrame.setLocation(
ShoppyPOSApp.frame.mainDesktopPane.getWidth()/ 2 - internalFrame.getWidth()/2,
ShoppyPOSApp.frame.mainDesktopPane.getHeight()/2 - internalFrame.getHeight()/2
);
ShoppyPOSApp.frame.mainDesktopPane.add(internalFrame);
}
internalFrame.setSelected(true);
} catch (Exception e) {
log.debug(e.toString(), null);
}
}