Adicionando ícones ao System Tray - Dica

Aprenda nesta dica como colocar o ícone de seu programa no System Tray.

Adicionando ícones ao System Tray

Utilizando este código, você pode adicionar um ícone ao lado do relógio (System Tray).

public class systemTray {

<SPAN lang=EN-US >  </SPAN><B><SPAN lang=EN-US >public static void </SPAN></B><SPAN lang=EN-US >main(String[] args) {</SPAN>

<SPAN lang=EN-US >Display display = Display.getDefault();</SPAN>
<SPAN lang=EN-US >Tray tray = display.getSystemTray();</SPAN>
<SPAN lang=EN-US >TrayItem item = </SPAN><B><SPAN lang=EN-US >new </SPAN></B><SPAN lang=EN-US >TrayItem(tray, </SPAN><SPAN lang=EN-US >0</SPAN><SPAN lang=EN-US >);</SPAN>
<SPAN lang=EN-US >Image img = </SPAN><B><SPAN lang=EN-US >new </SPAN></B><SPAN lang=EN-US >Image(display, </SPAN><SPAN lang=EN-US >"c:\\picture.jpg"</SPAN><SPAN lang=EN-US >);</SPAN>
<SPAN lang=EN-US >Item.setImage(img);</SPAN>
<SPAN lang=EN-US >Item.setToolTipText(</SPAN><SPAN lang=EN-US >"SWT Tray in action"</SPAN><SPAN lang=EN-US >);</SPAN>

<SPAN lang=EN-US >  </SPAN><SPAN lang=EN-US >}</SPAN>
<SPAN lang=EN-US >}</SPAN>

 

Artigos relacionados