mirror of
				https://github.com/lov3b/Schack.git
				synced 2025-11-04 07:00:21 +01:00 
			
		
		
		
	Love suger på att lägga till repaint
This commit is contained in:
		@@ -30,10 +30,10 @@ public class Board extends JPanel implements MouseListener {
 | 
			
		||||
    private Piece[][] initPieces() throws IOException {
 | 
			
		||||
 | 
			
		||||
        Piece[][] piecesRet = {
 | 
			
		||||
            {new Rook(false, new Point(0, 0)), null, null, null, null, null, null, new Rook(true, new Point(0, 7))},
 | 
			
		||||
            {new Rook(false, new Point(0, 0)), null, null, new Pawn(false, new Point(0,4)), null, null, null, new Rook(true, new Point(0, 7))},
 | 
			
		||||
            {new Horse(false, true, new Point(1, 0)), null, null, null, null, null, null, new Horse(true, true, new Point(1, 7))},
 | 
			
		||||
            {new Bishop(false, new Point(2, 0)), null, null, null, null, null, null, new Bishop(true, new Point(2, 7))},
 | 
			
		||||
            {new Queen(false, new Point(3, 0)), null, null, null, new Queen(false, new Point(3, 4)), null, null, new Queen(true, new Point(3, 7))},
 | 
			
		||||
            {new Queen(false, new Point(3, 0)), null, null, null, new Pawn(false, new Point(3, 4)), null, null, new Queen(true, new Point(3, 7))},
 | 
			
		||||
            {new King(false), null, null, null, null, null, null, new King(true)},
 | 
			
		||||
            {null, null, null, null, null, null, null, new King(false, new Point(5, 7))},
 | 
			
		||||
            {null, null, null, null, null, null, null, null},
 | 
			
		||||
@@ -197,6 +197,7 @@ public class Board extends JPanel implements MouseListener {
 | 
			
		||||
        } else {
 | 
			
		||||
            validMovesToDraw.clear();
 | 
			
		||||
        }
 | 
			
		||||
       getParent().repaint();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ import javax.swing.UIManager;
 | 
			
		||||
 *
 | 
			
		||||
 * @author Love Billenius & Simon Hansson
 | 
			
		||||
 */
 | 
			
		||||
public class Schack extends JFrame implements Runnable {
 | 
			
		||||
public class Schack extends JFrame{
 | 
			
		||||
 | 
			
		||||
    public Schack() throws IOException {
 | 
			
		||||
        setTitle("Schack");
 | 
			
		||||
@@ -26,7 +26,7 @@ public class Schack extends JFrame implements Runnable {
 | 
			
		||||
        Board board = new Board();
 | 
			
		||||
        setContentPane(board);
 | 
			
		||||
        getContentPane().addMouseListener(board);
 | 
			
		||||
        Thread thread = new Thread(this);
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
        // Set theme
 | 
			
		||||
        try {
 | 
			
		||||
@@ -74,7 +74,7 @@ public class Schack extends JFrame implements Runnable {
 | 
			
		||||
        pack();
 | 
			
		||||
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 | 
			
		||||
        setVisible(true);
 | 
			
		||||
        this.run();
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -83,18 +83,6 @@ public class Schack extends JFrame implements Runnable {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void run() {
 | 
			
		||||
 | 
			
		||||
        while (true) {
 | 
			
		||||
            try {
 | 
			
		||||
                Thread.sleep(12);
 | 
			
		||||
            } catch (InterruptedException ex) {
 | 
			
		||||
                Logger.getLogger(Schack.class.getName()).log(Level.SEVERE, null, ex);
 | 
			
		||||
            }
 | 
			
		||||
            repaint();
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
   
 | 
			
		||||
   
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user