2013-01-13 1 views
0

가능한 중복 :
How can I put my Java program in the system tray?간단한 방법은 시스템 트레이에 창을 추가 할

나는 자바에 알림 시스템을 만드는 중이라서

, 나는 프로그램이 시스템 트레이에 표시하려면, 작업 표시 줄 대신에 다음을 시도했습니다.

notification.setExtendedState(JFrame.ICONIFIED); 

이 기능은 작동하지 않을뿐만 아니라 지옥 컴퓨터 현재 코드 : ALSO

public static void notify(String line1, String line2, String imagepath, int style){ 
     GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); 
     int width = gd.getDisplayMode().getWidth(); 
     int swidth = width - 320; 

     JFrame notification = new JFrame(); 
     JPanel main = new JPanel(new FlowLayout(FlowLayout.RIGHT)); 
     main.setLayout(new GridLayout(2 , 1)); 



     JLabel notifyline1 = new JLabel(); 
     notifyline1.setText(line1); 
     notifyline1.setFont(new Font("Minecraft",1 , 16)); 
     notifyline1.setForeground(new Color(242, 238, 17)); 
     main.add(notifyline1); 

     JLabel notifyline2 = new JLabel(); 
     notifyline2.setText(line2); 
     notifyline1.setFont(new Font("Minecraft",1 , 12)); 
     notifyline1.setForeground(Color.black); 
     main.add(notifyline1); 

     notification.add(main); 
     notification.setExtendedState(JFrame.ICONIFIED); 
     notification.setSize(new Dimension(320,64)); 
     notification.setLocation(swidth, 0); 
     notification.setUndecorated(true); 
     notification.setVisible(true); 
    } 

, 돌 하나도 돌 2 새를 죽일 수는 JLabel의 색상 수있는 방법이

label1.setForegroundColor(new Color(100, 100, 100)); 

답변

0

자바 응용 프로그램을 최소화 할 수 있습니다 TrayIcon 클래스가 시도 SystemTray에 있습니다. 작업 예제 here을 볼 수 있습니다.

관련 문제