Results 1 to 2 of 2
  1. #1
    nickburris is offline Member
    Join Date
    Jan 2011
    Posts
    30
    Rep Power
    0

    Default Why doesn't this put the images on the screen?

    Java Code:
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.RenderingHints;
    import javax.swing.*;
    
    public class Nick extends JFrame{
    	public static void main(String[] args){
    		
    		TheWindow w = new TheWindow();
    		w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		w.setSize(700,500);
    		w.setVisible(true);
    	}
    	public Nick(){
    		super("ProjectN (Un-named game)");
    	}
    	private Image bg;
    	private Image Start;
    	
    	public void loadPics(){
    		bg = new ImageIcon(getClass().getResource("back.jpg")).getImage();
    		Start = new ImageIcon(getClass().getResource("Start.png")).getImage();
    		
    	}
    	public void draw(Graphics g){
    		super.paint(g);
    		if(g instanceof Graphics2D){
    			Graphics2D g2 = (Graphics2D)g;
    			g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    		}
    		g.drawImage(bg,0,0,null);
    		g.drawImage(Start,10,10,null);
    	}
    	
    }
    When I run it, the images don't show up, but they should because I have the
    Java Code:
    g.drawImage(bg,0,0,null);
    and
    Java Code:
    g.drawImage(Start,10,10,null);
    ..right?

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    You have your answer here:
    Can't put the image on the screen??
    I suggest you actually read the replies - if they don't make sense then ask for clarification (FWIW, the problem in this example is completely different (what is TheWindow?))
    Last edited by doWhile; 01-31-2011 at 08:33 PM.

Similar Threads

  1. Move from one screen fto other screen
    By jprgmr75 in forum CLDC and MIDP
    Replies: 0
    Last Post: 01-02-2011, 06:32 PM
  2. Replies: 4
    Last Post: 12-16-2010, 04:32 PM
  3. How to do a screen capture of content on web page/join 2 images
    By raabie in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 08-27-2010, 01:02 PM
  4. Can't show images onto the screen
    By javaexplorer in forum AWT / Swing
    Replies: 9
    Last Post: 01-14-2010, 06:31 PM
  5. Blank Screen while navigating from one screen to another
    By mohana.krishna in forum Java Servlet
    Replies: 0
    Last Post: 03-03-2009, 05:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •