#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    19
    Rep Power
    0

    Java Display pics help


    Hello,
    I have been asking for a lot of help but I cant find the answer anywhere else. My problem is that when I run the program it is supposed to run my background and my image that I made.
    But instead I makes a pink line at the bottom and white at the top.
    Code:
    import java.awt.*;
    import java.awt.Image;
    
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    public class Images2 extends JFrame {
    	public static void main(String[] args) {
    		DisplayMode dm = new DisplayMode(800,600,16, DisplayMode.REFRESH_RATE_UNKNOWN);
    		Images2 I = new Images2();
    		I.run(dm);
    	}
    	
    	private Screen s;
    	private Image bg;
    	private Image pic;
    	private boolean loaded;
    	//run
    	public void run(DisplayMode dm){
    		setBackground(Color.PINK);
    		setForeground(Color.WHITE);
    		setFont(new Font("Arial", Font.PLAIN, 24));
    		loaded = false;
    		
    		s = new Screen();
    		try{
    		    s.setfullScreen(dm, this);
    		    loadpics();
    			try{
    				Thread.sleep(5000);
    			}catch(Exception ex){}
    		}finally{
    			s.restoreScreen();
    		}
    	}	
    	// loading images
    	private void loadpics() {
    		bg = new ImageIcon("/Users/*********/Documents/back2.JPG").getImage();
    		pic = new ImageIcon("/Users/*********/Documents/face.PNG").getImage();
    		loaded = true;
    		repaint();
    	}
    
    	public void paint(Graphics g){
    		if(g instanceof Graphics2D){
    			Graphics2D g2 = (Graphics2D)g;
    			g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    		}
    		if(loaded){
    			g.drawImage(bg,0,0,null);
    			g.drawImage(pic,170,180, null);
    		}
  2. #2
  3. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    Code:
    g.drawImage(bg,0,0,null);
    			g.drawImage(pic,170,180, null);
    Try changing null to this

IMN logo majestic logo threadwatch logo seochat tools logo