0

인사말,JDesktopPane 및 JInternalFrame 도움!

중복되는 JInternalFrames를 JDesktopPane으로 제한하는 것과 관련하여 질문이 있습니다. 기본적으로 JInternalFrame 인스턴스를 JDesktopPane에 추가하는 것이 포괄적입니다. 그러나 JDesktopPane에서 같은 인스턴스의 중복 JInternalFrame을 제한하고 해당 인스턴스를 JDesktopPane의 최상위 레이어로 지정하십시오.

어떻게 구현할 수 있습니까? 모든 인스턴스를 ArrayList에 저장하고 execute에 대한 인스턴스가 이미 열려 있는지 여부를 확인하겠습니까?

회신을 보내 주시면 대단히 감사하겠습니다.

감사합니다, 시릴 H.

답변

0
/** 
* method to search for active internal frame windows 
* and return true or false depending on the outcome. this method uses internalframe names 
*/ 
public boolean searchIFrame(String search, JInternalFrame frame[]) 
{ 
    for(int i = 0; i < frame.length; i++) 
     if(frame[i].getTitle().toString().equals(search)) 
      return true; 
     return false; 
} 

//its implementation in your program. "Information Form" is the internalframe's name 
//jdesk is the desktoppane object or instance 
boolean srch = searchIFrame("Information Form", jdesk.getAllFrames()); 
    if(!srch) {   
       VisitationForm at = new VisitationForm(); 
       at.pack(); 
       jdesk.add(at); 

       try 
       { 
        at.setSelected(true); 
        at.setVisible(true); 
        // We're done, so clear the feedback message 
        //bar.setString(" "); 
        //bar.setIndeterminate(false); 
        at.requestFocus(); 

       } 
       catch (PropertyVetoException pve) 
       { 
        //bar.setString(" "); 
        //bar.setIndeterminate(false); 

        // Then display the error in a dialog box 
        System.out.println(pve); 
       } 

      }