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.AWTException;
import java.awt.BorderLayout;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.*;
public class RobotBackSlashExample extends JFrame implements ActionListener {
private JTextArea tArea = new JTextArea();
private JButton btn = new JButton("Press Backslash");
private Robot rob;
public RobotBackSlashExample() {
super("RobotBackSlashExample");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationByPlatform(true);
this.setAlwaysOnTop(true);
btn.addActionListener(this);
btn.setFocusable(false);
try {
rob = new Robot();
} catch (AWTException e) {
e.printStackTrace();
}
this.add(new JScrollPane(tArea), BorderLayout.CENTER);
this.add(btn, BorderLayout.SOUTH);
this.pack();
this.setVisible(true);
}
public static void main(String[] args) {
new RobotBackSlashExample();
}
public void actionPerformed(ActionEvent e) {
// test1(); //Funktioniert nicht
test2();
}
public void test1() {
rob.keyPress(KeyEvent.VK_BACK_SLASH);
rob.keyRelease(KeyEvent.VK_BACK_SLASH);
}
public void test2() {
rob.keyPress(KeyEvent.VK_ALT);
rob.keyPress(KeyEvent.VK_NUMPAD9);
rob.keyRelease(KeyEvent.VK_NUMPAD9);
rob.keyPress(KeyEvent.VK_NUMPAD2);
rob.keyRelease(KeyEvent.VK_NUMPAD2);
rob.keyRelease(KeyEvent.VK_ALT);
}
}