Note that there are some explanatory texts on larger screens.

plurals
  1. POIssues with loading Images into a Graphics2D
    primarykey
    data
    text
    <p>I'm trying to load Images into this program and it won't work and I've played around to make sure that I had the directories right and everything, but now I'm kinda at a lost. The draw function called in by the PersonFront class works fine, but not the Image that is supposed to be in it as well. I can change dimensions and all that, but it continues to not show any images.</p> <pre><code> import java.awt.*; import java.awt.event.*; import java.applet.*; import javax.swing.*; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; public class GameViewer extends Applet implements KeyListener { final static int NUM_WIDTH=14; final static int NUM_HEIGHT=7; private int startX = 100; private int startY = 40; public void init() { setBackground(Color.GRAY); addKeyListener(this); setFocusable(true); requestFocusInWindow(); } public void start() {} public void paint(Graphics g) { Graphics2D g2 =(Graphics2D) g; Image wood = getImage(getCodeBase(), "Resources/Images/Environment/woodfloor.png"); Image wall = getImage(getCodeBase(), "wall.jpg"); Image counter = getImage(getCodeBase(), "resources/images/environment/counter.jpg"); Image cab_right = getImage(getCodeBase(), "resources/images/environment/cabinet_right.jpg"); Image cab_left = getImage(getCodeBase(), "resources/images/environment/cabinet_left.jpg"); Image shirt = getImage(getCodeBase(), "resources/Images/Character_Wear/Shirts/shirt_red.png"); Image pants = getImage(getCodeBase(),"resources/Images/Character_Wear/Pants/pants_limegreen.png"); g2.drawImage(wood,0,0,null); //for(int q=0; q&lt;NUM_WIDTH; q++) // for(int z=0; z&lt;NUM_HEIGHT; z++) // { // g2.drawImage(wood, q*64, z*64, null); // g2.drawImage(wall, 0, 128+(16*z), null); // } PersonFront stat = new PersonFront(startX,startY,shirt,pants); stat.draw(g2); } public void keyPressed(KeyEvent key) { if (key.getKeyCode() == key.VK_D) { startX += 32; repaint(); } if(key.getKeyCode() == key.VK_A) { startX -= 32; repaint(); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload