Advertisement
pendekar_langit

image_background_dekstop

Mar 3rd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. //buat class baru bernama BackgroundDekstop dan sesuaikan script dengan yang di bawah
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. package image;
  8.  
  9. import java.awt.Graphics;
  10. import java.awt.Graphics2D;
  11. import java.awt.Image;
  12. import javax.swing.ImageIcon;
  13. import javax.swing.JDesktopPane;
  14.  
  15. /**
  16.  *
  17.  * @author root
  18.  */
  19. public class BackgroundDekstop extends JDesktopPane{
  20.     @Override
  21.     protected void paintComponent(Graphics g) {
  22.         Graphics2D graphics = (Graphics2D) g.create();
  23.         Image img = new ImageIcon(getClass().getResource("background.jpg")).getImage();
  24.         graphics.drawImage(img, 0, 0, getWidth(), getHeight(), null);
  25.         graphics.dispose();
  26.     }
  27. }
  28.  
  29.  
  30. //untuk mengaplikasikan script diatas, klik kanan jdekstop pane -> customize code -> ubah line pertama menjadi Main_Desktop = new BackgroundDekstop(); , jangan lupa setting combo box di kiri menjadi customize code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement