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.
/*
* Created on 19.05.2005@12:32:11 by Darimont
*
* TODO Licence info
*/
package de.tutorials;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import javax.swing.JFrame;
/**
* @author Darimont
*
* TODO Explain me
*/
public class RectanglePaintingExample extends JFrame {
private Point startPoint;
public RectanglePaintingExample() {
super("RectanglePaintingExample");
setDefaultCloseOperation(EXIT_ON_CLOSE);
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
startPoint = e.getPoint();
}
public void mouseReleased(MouseEvent e) {
startPoint = null;
}
});
addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
Point p = e.getPoint();
if (startPoint != null) {
Graphics g = getGraphics();
g.clearRect(0, 0, 640, 480);
int w = p.x - startPoint.x;
int h = p.y - startPoint.y;
int x = startPoint.x;
int y = startPoint.y;
if (h < 0) {
y += h;
}
if (w < 0) {
x += w;
}
g.drawRect(x, y, Math.abs(w), Math.abs(h));
}
}
});
setSize(640, 480);
setVisible(true);
}
public static void main(String[] args) {
new RectanglePaintingExample();
}
}