somehow, the images are not showing... but I know the elements have been added. what could be wrong???Code:class GoBangTile extends JComponent{ private final static Image imgDisplay[] = new Image[3]; protected final static int IMG_NASHI; protected final static int IMG_MARU; protected final static int IMG_BATSU; private int bImgType; static{ IMG_NASHI = 0; IMG_MARU = 1; IMG_BATSU = 2; imgDisplay[IMG_NASHI] = new ImageIcon("nashi.PNG").getImage(); imgDisplay[IMG_MARU] = new ImageIcon("maru.PNG").getImage(); imgDisplay[IMG_BATSU] = new ImageIcon("batsu.PNG").getImage(); } protected GoBangTile(){ System.out.println("Doing tile, getting images"); bImgType = IMG_NASHI; this.setPreferredSize(new Dimension(100, 100)); this.setSize(new Dimension(100, 100)); } protected void setImage(int bNewImageType){ if(bNewImageType <= 2 && bNewImageType >= 0){ bImgType = bNewImageType; } repaint(); } /* (non-Javadoc) * @see java.awt.Component#paint(java.awt.Graphics) */ public void paint(Graphics g) { // TODO Auto-generated method stub //Graphics2D g2d = (Graphics2D)g; //g2d.drawImage(imgDisplay[bImgType], 0, 0, this); g.drawImage(imgDisplay[bImgType], 0, 0, this); super.paint(g); } }![]()




Reply With Quote