Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
/**
*
*/
package de.tutorials;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.Timer;
/**
* @author Tom
*
*/
public class TaskBarNotificationExample extends JFrame {
public TaskBarNotificationExample() {
super("TaskBarNotificationExample");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(320, 240);
setVisible(true);
Timer timer = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (hasFocus()) {
System.out.println("has focus");
} else {
System.out.println("blink");
setVisible(true);
}
}
});
timer.setRepeats(true);
timer.start();
}
/**
* @param args
*/
public static void main(String[] args) {
new TaskBarNotificationExample();
}
}
public class Blink extends Thread {
private JFrame frame = null;
public Blink(JFrame frame) {
super();
this.frame = frame;
}
public void run() {
super.run();
while(true) {
try {
if(isInterrupted())
break;
if(!frame.hasFocus()) {
frame.setVisible(true);
System.out.println("blink");
} else
break;
Thread.sleep(1000);
} catch (InterruptedException e) {
break;
}
}
System.out.println("Blink beendet");
}
}