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 10.02.2005@21:32:49
*
* TODO Licence info
*/
package de.tutorials;
import java.util.Timer;
import java.util.TimerTask;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* @author Administrator
*
* TODO Explain me
*/
public class SWTTextScroller {
public static void main(String[] args) {
new SWTTextScroller().start();
}
/**
*
*/
private void start() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("SWTTextScroller");
shell.setLayout(new FillLayout());
shell.setSize(150, 75);
TextScroller scroller = new TextScroller("tutorials.de", shell,
SWT.BORDER);
scroller.setSize(150, 75);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
class TextScroller extends Canvas {
private String text;
private Timer timer;
private int x;
private Runnable run = new Runnable() {
public void run() {
GC gc = new GC(TextScroller.this);
Color c = TextScroller.this.getBackground();
Color cOld = gc.getForeground();
if (x++ > 150) {
x = -50;
}
gc.setForeground(c);
gc.fillRectangle(0, 10, 150, 20);
gc.setForeground(cOld);
gc.drawText(text, x, 15);
c.dispose();
cOld.dispose();
gc.dispose();
}
};
private TimerTask task = new TimerTask() {
public void run() {
if (TextScroller.this.isDisposed()) {
timer.cancel();
return;
}
TextScroller.this.getDisplay().asyncExec(run);
}
};
/**
* @param arg0
* @param arg1
*/
public TextScroller(String text, Composite arg0, int arg1) {
super(arg0, arg1);
this.text = text;
timer = new Timer();
timer.schedule(task, 100L, 25L);
}
}
}