0 Members and 1 Guest are viewing this topic.
package screenrepeater;import java.awt.*;import java.awt.image.*;import javax.swing.*;public class ScreenRepeater extends JFrame { Image background = null; boolean bglock = false; public static void main(String[] args) { ScreenRepeater sr = new ScreenRepeater(); sr.setSize(200, 200); sr.setAlwaysOnTop(true); sr.setVisible(true); sr.setDefaultCloseOperation(sr.EXIT_ON_CLOSE); } public ScreenRepeater() { Thread ssUpdater = new Thread() { public void run() { AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC, 0.2f); while (true) { long time = System.currentTimeMillis(); try { background = new Robot().createScreenCapture(new Rectangle(0, 0, getWidth(), getHeight())); temp = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_4BYTE_ABGR); Graphics2D g2 = (Graphics2D)temp.getGraphics(); g2.setComposite(ac); g2.drawImage(background, 0, 0, null); setTitle((1d / (double)(System.currentTimeMillis() - time) * 1000) + ""); sleep(1); } catch (Exception ex) { ex.printStackTrace(); } } } }; ssUpdater.start(); Thread repainter = new Thread() { public void run() { while (true) { try { repaint(); sleep(10); } catch (Exception ex) { ex.printStackTrace(); } } } }; repainter.start(); } BufferedImage temp; @Override public void paint(Graphics g) { g.drawImage(temp, 4, 25, null); }}