Swing doesn’t flicker when I don’t move stuff around(except for the Tile Image)
public void moveOverTile(Tile t) {
Point leftTop = mapPanel.getLeftTop();
Dimension mapPanelDim = mapPanel.getSize();
if (t == null) {
return;
}
// Is the current Tile position on the left side of the mapPanel(viewArea)
boolean move = leftTop.x + (t.getCol() * map.getTileSize()) <= mapPanel.getWidth() / 2;
// check for change
if (leftSide != move) {
leftSide = move;
if (leftSide) {
tileInfo.setAbsolutePosition(mapPanelDim, TileInfo.Position.LOWER_RIGHT);
} else {
tileInfo.setAbsolutePosition(mapPanelDim, TileInfo.Position.LOWER_LEFT);
}
}
}
TileInfo:
public void setAbsolutePosition(Dimension dim, Position pos) {
Point currentLocation = getLocation();
int x = 0, y = 0;
switch (pos) {
case LOWER_LEFT:
x = LEFT_MARGIN;
y = dim.height - HEIGHT - BUTTOM_MARGIN;
break;
case LOWER_RIGHT:
x = dim.width - WIDTH - LEFT_MARGIN;
y = dim.height - HEIGHT - BUTTOM_MARGIN;
break;
}
// If one coordinate changed we need to change it's position!
if (x != currentLocation.x || y != currentLocation.y) {
setLocation(x, y);
} else {
System.out.println("stop calling this function, i already changed...");
}
}
I don’t see the System.out message so that’s good 
before i was setting the location for every update, but that wasen’t the cause of the problem… I still get Flickering.
When setLocation is called i can see a rectangle from old to new position being drawen in the background color(grey)
the rectangle has the same height as TileInfo.getHeight and the width is the same as TileInfo.getWidth()
what can be the cause of this rectangle?
I think it’s some kind of dirty rectangle but that’s supposed to be blocked?
I disabled automatic repaintings as in http://www.java-gaming.org/forums/index.php?topic=15140.15
so how does that rectangle get’s there anyway?