When I see my application, it draws my image not on (0,0) but somewhere middle in my program, So I debug my program,and I saw that the clipRegion.lox is 456 and loy is 130 and this is the location that program draw (0,0). So I think that Clip Region position is wrong, but I don't know how to fix it. Any help please?
code:
public void changeState(int bef,int cur){
if(bef==1){
if(cur==2){
intro.setVisible(false);
this.setContentPane(play);
play.init();
play.setVisible(true);
}
}
}
This is when first my Panel is started. In play.init() I set my socket to connect with server program, and start sound file. That is all.
public void paintComponent(Graphics g){
super.paintComponent(g);
this.setBackground(new Color(255,255,255));
g.drawImage(backgroundImg, 0, 0, this);
g.drawImage(player, 368, 280, this);
for(int i=0;i<60;i++){
for(int j=0;j<100;j++){
if(map[i][j]==1){
g.drawImage(stone, (j-10)*32-dx, (i-10)*32, this);
}
else if(map[i][j]==2){
if(i>0&&map[i-1][j]==0) g.drawImage(grass, (j-10)*32-dx, (i-10)*32, this);
else g.drawImage(dirt, (j-10)*32-dx,(i-10)*32,this);
}
}
}
g.drawString(servermessage, 320, 200);
}
- I erased my Println code and Thread Sleep Code. It was just for debugging and when I deleted however, nothing changed.
Plus, I repainted it, and it draws in (0,0) but it doesn't draw full screen.
I think that drawn image is the same size as (456,130) to (800,600) so I think the picture is cut out.
I can't post my picture because of low reputation... Any help too?