Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. // show a graphic on top of your xwindows display (full-screen) from a PNG file
  2. // by misan, September 2017
  3.  
  4. import java.awt.*;
  5. import javax.swing.*;
  6. import java.awt.geom.*;
  7. import java.util.*;
  8. import java.io.*;
  9. import javax.imageio.*;
  10. import java.awt.image.BufferedImage;
  11.  
  12. public class FullscreenTest {
  13.  
  14.     public static void main(String[] args) {
  15.         JFrame frame = new JFrame();
  16.         Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
  17.         frame.setSize(dim);
  18.         frame.setUndecorated(true);
  19.         frame.add(new ImagePanel());
  20.         frame.setVisible(true);
  21.     }
  22. }
  23.  
  24. class ImagePanel extends JPanel{
  25.  
  26.     private BufferedImage image;
  27.  
  28.     public ImagePanel() {
  29.        try {                
  30.           image = ImageIO.read(new File("cernicalo2.png"));
  31.        } catch (IOException ex) {
  32.             // handle exception...
  33.        }
  34.     }
  35.  
  36.     @Override
  37.     protected void paintComponent(Graphics g) {
  38.         super.paintComponent(g);
  39.         g.drawImage(image, 0, 0, this); // see javadoc for more info on the parameters            
  40.     }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement