Dall'ultima versione di java (java 6) e' possibile accedere alla SystemTray e settare un'icona.
Il lampeggiamento lo puoi gestire attraverso thread o timer.
Posto un esempio banale con un timer.
codice:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
public class TestSysTray extends JFrame implements ActionListener, WindowListener {
private SystemTray sys;
private TrayIcon icon;
private Image immagine;
private Image immagineVuota;
private Timer timer;
private JButton start;
private JButton stop;
private JPanel pannello;
private boolean flag = true;
/** Creates a new instance of TestSysTray */
public TestSysTray() {
//Disegno il Frame e i suoi componenti
super("test");
pannello = new JPanel();
start = new JButton("start");
start.addActionListener(this);
stop = new JButton("stop");
stop.addActionListener(this);
pannello.add(start);
pannello.add(stop);
this.setContentPane(pannello);
//Setto la parte che si occupa del lampeggiamento
timer = new Timer(500, this);
immagine = Toolkit.getDefaultToolkit().createImage("C:\\Documents and Settings\\Simone\\Desktop\\red.PNG");
immagineVuota = new BufferedImage(3,3,BufferedImage.TYPE_INT_ARGB);
if(SystemTray.isSupported()) {
sys = SystemTray.getSystemTray();
icon = new TrayIcon(immagine);
try {
sys.add(icon);
} catch (AWTException ex) {
ex.printStackTrace();
}
}
//ridimensiono il frame, setto l'operazione di chiusura e lo rendo visibile
this.pack();
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.addWindowListener(this);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
//Lampeggiamento. Ad ogni botta di Timer cambio l'immagine
if(source.equals(timer)){
if(flag) {
icon.setImage(immagineVuota);
} else {
icon.setImage(immagine);
}
flag = !flag;
} else if(source.equals(start)) {
timer.start();
} else if(source.equals(stop)) {
timer.stop();
icon.setImage(immagine);
}
}
public void windowOpened(WindowEvent e) {}
public void windowClosing(WindowEvent e) {
//Alla chiusura rimuovo l'icona dalla SystemTray
sys.remove(icon);
this.dispose();
}
public void windowClosed(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public static void main(String[] args) {
new TestSysTray();
}
}