Commit 12c0b965 authored by YuFan Jia's avatar YuFan Jia 💤
Browse files

feat( ):

parent c14c7efd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@ public class ChessPanel extends BasicComponent {
    private static int size = 8;
    private ChessPiece playersChess;
    ImageIcon emptyImg = new ImageIcon("Resources/empty.png");
    ImageIcon whiteImg = new ImageIcon("Resources/white1.png");
    ImageIcon blackImg = new ImageIcon("Resources/black1.png");
    ImageIcon whiteImg = new ImageIcon("Resources/white.png");
    ImageIcon blackImg = new ImageIcon("Resources/black.png");
    ImageIcon image;

    ChessPanel(int row, int col) {
+20 −3
Original line number Diff line number Diff line
package GameUI;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JPanel;
import javax.swing.JProgressBar;

public class TopBar extends JPanel {
    private JProgressBar scoreBar = new JProgressBar();
    class customBar extends JProgressBar {
        customBar() {
            super();
        }

        @Override
        public Dimension getPreferredSize() {
            Dimension space = getParent().getSize();
            int width = (int) space.getWidth() - 100;
            return new Dimension(width, 20);
        }
    }

    private JProgressBar scoreBar = new customBar();

    public TopBar(/* int x, int y, */ int width, int height) {
        this.add(scoreBar);
        // this.scoreBar.setLocation(x, y);
        this.scoreBar.setSize(width, height);
        // TODO set to proper size & location
        this.scoreBar.setFont(new Font("Calibri", Font.PLAIN, 20));
        this.scoreBar.setFont(new Font("Calibri", Font.PLAIN, 18));
        this.scoreBar.setForeground(Color.BLACK);
        this.setScoreBar(2, 2);
    }

@@ -22,7 +39,7 @@ public class TopBar extends JPanel {
        this.scoreBar.setValue(vs100);
        this.scoreBar.setIndeterminate(false);
        this.scoreBar.setStringPainted(true);
        this.scoreBar.setString(String.format("BLACK: %d  <<>>  WHITE: %d", blackScore, whiteScore));
        this.scoreBar.setString(String.format("BLACK: %3d  <<>>  WHITE: %3d", blackScore, whiteScore));
    }

}