2013-07-01 8 views
0

나는 현재 시스템 트레이에 JFrame의 최소화를 다루는 그리고 난 그렇게 성공적으로 수행 한 최소화 된 경우 아이콘 sys 인 트레이에 표시되지 :JFrame의 - JFrame의 아래에 표시된대로

// 
    URL resource = panel.getClass().getClassLoader().getResource("boston.png"); 
    System.out.println("rfc95Panel.getClass().getClassLoader().getResource() is: " + rfc95Panel.getClass().getClassLoader().getResource("boston.png")); 

    Image image = Toolkit.getDefaultToolkit().getImage(resource); 

    // 
    frame.setIconImage(image); 

    // 
    if (SystemTray.isSupported()) { 
     final TrayIcon icon = new TrayIcon(image); 
     icon.setToolTip("Program minimised"); 

     // 
     icon.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent e) { 
       frame.setVisible(true); 
       frame.setExtendedState(frame.NORMAL); 
       getSystemTray().remove(icon); 
      } 
     }); 

     // Adds the specified window state listener to receive window events 
     // from this window. If l is null, no exception is thrown and no action 
     // is performed. 
     frame.addWindowListener(new WindowAdapter() { 

      @Override 
      public void windowIconified(WindowEvent e) { 
       frame.setVisible(false); 
       try { 
        getSystemTray().add(icon); 
       } catch (AWTException e1) { 
        e1.printStackTrace(); 
       } 
      } 
     }); 
    } 

문제는 나는 시스템 트레이 예를 열고 이미지/아이콘을 볼 수 없습니다 최소화 때이 도구 팁을 볼 수 있지만 나는 내 프로그램에 관련된 아이콘을 볼 수 없습니다 -

sys tray image

모든 아래 이미지 참조 내가 놓친 것에 대한 아이디어? 나는 그것이 뭔가 기본적인 것 같아요.

+1

bosten.png 파일을 올바르게로드하고 있습니까? – Grammin

+1

빨리 도움을 받으려면 [SSCCE] (http://sscce.org/)를 게시하십시오. –

+0

안녕하세요 Grammin, 답장을 보내 주셔서 감사합니다 .. 이미지가 올바르게로드됩니다 .. 나는이 이미지를 rfc95Panel.getClass(). getClassLoader(). getResource() : file :/C : /Users/TestProject/bin/boston.png .. 프로그램이 열릴 때 작업 표시 줄의 이미지를 볼 수도 있습니다 .. – TokTok123

답변

1

위의 문제에 대한 간단한 대답은 sys tray 아이콘으로 사용하려는 이미지의 크기입니다. 기본적으로 내 치수는 64 x 64이지만 이상적으로 크기가 작아서 이미지가 16으로 축소되었습니다.