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.Graphics2D;
import java.awt.image.BufferStrategy;
import javax.swing.JFrame;
public class FlyBall extends JFrame {
private BufferStrategy strategy;
private Thread animator = new Thread(){
int x, y;
public void run(){
while(true){
Graphics2D g = (Graphics2D)strategy.getDrawGraphics();
g.clearRect(0,0,320,240);
g.fillOval((x+=4) % 320,(y+=3) % 240,25,25);
g.dispose();
strategy.show();
try {
Thread.sleep(20L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
public FlyBall(){
super("BallJumb");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setIgnoreRepaint(true);
setSize(320,240);
setVisible(true);
createBufferStrategy(2);
strategy = getBufferStrategy();
}
public static void main(String[] args) {
new FlyBall().start();
}
private void start() {
animator.start();
}
}