Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1.  
  2. import java.awt.AlphaComposite;
  3. import java.awt.Canvas;
  4. import java.awt.Color;
  5. import java.awt.Dimension;
  6. import java.awt.Font;
  7. import java.awt.Graphics;
  8. import java.awt.Graphics2D;
  9. import javax.swing.JFrame;
  10.  
  11. /**
  12.  *
  13.  * @author Colby
  14.  */
  15. public class NewMain {
  16.  
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     public static void main(String[] args) {
  21.  
  22.         Canvas c = new Canvas() {
  23.  
  24.             @Override
  25.             public void paint(Graphics g) {
  26.                 Graphics2D g2d = (Graphics2D) g.create();
  27.                 g2d.setComposite(AlphaComposite.SrcOver.derive(0.0f));
  28.                 g2d.fillRect(0, 0, 800, 600);
  29.                
  30.                 g2d.setComposite(AlphaComposite.SrcOver.derive(1f));
  31.                 g2d.setColor(Color.BLACK);
  32.                 g2d.setFont(new Font("TimesRoman", Font.PLAIN, 48));
  33.                 g2d.drawString("HELLO WORLD!!!!", 10, 100);
  34.                
  35.                 g2d.dispose();
  36.             }
  37.         };
  38.  
  39.         JFrame frame = new JFrame() {
  40.  
  41.             @Override
  42.             public void paint(Graphics g) {
  43.                 Graphics2D g2d = (Graphics2D) g.create();
  44.                 g2d.setComposite(AlphaComposite.SrcOver.derive(Float.MIN_VALUE));
  45.                 super.paint(g2d);
  46.                 g2d.dispose();
  47.             }
  48.         };
  49.         frame.setUndecorated(true);
  50.         frame.setBackground(new Color(0, 255, 0, 0));
  51.         frame.setPreferredSize(new Dimension(800, 600));
  52.         frame.getContentPane().add(c);
  53.        
  54.         frame.pack();
  55.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  56.         frame.setVisible(true);
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement