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.
import java.awt.Graphics;
import java.awt.image.BufferedImage;
public class FormPreviewPrint
extends java.awt.Canvas
{
private BufferedImage printImage = null;
public FormPreviewPrint()
{
this(null);
}
public FormPreviewPrint(BufferedImage printImage)
{
super();
this.printImage = printImage;
}
/**
* @return the printImage
*/
public BufferedImage getPrintImage()
{
return printImage;
}
/**
* @param printImage the printImage to set
*/
public void setPrintImage(BufferedImage printImage)
{
this.printImage = printImage;
}
public void paint(Graphics g)
{
if(printImage != null)
g.drawImage(printImage, 0, 0, this);
}
}
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
public class PreviewFrame
extends JFrame
{
private FormPreviewPrint previewPrint = null;
public PreviewFrame()
{
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(300, 300);
previewPrint = new FormPreviewPrint();
add(previewPrint, BorderLayout.CENTER);
previewPrint.setPrintImage(createPrintImage());
}
private BufferedImage createPrintImage()
{
BufferedImage p = new BufferedImage(900, 900, BufferedImage.TYPE_INT_RGB);
Graphics2D g = p.createGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.BLACK);
g.drawString("Hallo ich bins der Test!", 50, 50);
g.drawOval(90, 90, 100, 100);
return p;
}
public static void main(String[] args)
{
new PreviewFrame().setVisible(true);
}
}